Merge lp:~jtv/launchpad/buildfail-recipebuilder into lp:launchpad

Proposed by Jeroen T. Vermeulen on 2010-11-19
Status: Merged
Approved by: Jeroen T. Vermeulen on 2010-11-19
Approved revision: no longer in the source branch.
Merged at revision: 11951
Proposed branch: lp:~jtv/launchpad/buildfail-recipebuilder
Merge into: lp:launchpad
Diff against target: 79 lines (+12/-13)
1 file modified
lib/lp/translations/scripts/tests/test_message_sharing_migration.py (+12/-13)
To merge this branch: bzr merge lp:~jtv/launchpad/buildfail-recipebuilder
Reviewer Review Type Date Requested Status
Abel Deuring (community) code 2010-11-19 Approve on 2010-11-19
Review via email: mp+41282@code.launchpad.net

Commit Message

[r=adeuring][ui=none][no-qa] Fix spurious test failure in test_message_sharing_migration.

Description of the Change

This fixes spurious failures in one test, test_messagesCanStayDiverged. It also cleans up the test a bit, but the main thing is that just a switchDbUser apparently isn't always good enough. lp.testing.TestCase.becomeDbUser also throws in a commit, and that's what does the trick.

To post a comment you must log in.
Abel Deuring (adeuring) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/translations/scripts/tests/test_message_sharing_migration.py'
2--- lib/lp/translations/scripts/tests/test_message_sharing_migration.py 2010-10-05 00:08:16 +0000
3+++ lib/lp/translations/scripts/tests/test_message_sharing_migration.py 2010-11-19 11:06:31 +0000
4@@ -18,6 +18,7 @@
5 record_statements,
6 TestCaseWithFactory,
7 )
8+from lp.testing.sampledata import ADMIN_EMAIL
9 from lp.translations.interfaces.pofiletranslator import IPOFileTranslatorSet
10 from lp.translations.model.pomsgid import POMsgID
11 from lp.translations.model.potemplate import POTemplate
12@@ -62,8 +63,8 @@
13 # This test needs the privileges of rosettaadmin (to delete
14 # POTMsgSets) but it also needs to set up test conditions which
15 # requires other privileges.
16- self.layer.switchDbUser('postgres')
17- super(TestPOTMsgSetMerging, self).setUp(user='mark@example.com')
18+ super(TestPOTMsgSetMerging, self).setUp(user=ADMIN_EMAIL)
19+ self.becomeDbUser('postgres')
20 super(TestPOTMsgSetMerging, self).setUpProduct()
21
22 def test_matchedPOTMsgSetsShare(self):
23@@ -252,9 +253,9 @@
24 The matching POTMsgSets will be merged by the _mergePOTMsgSets
25 call.
26 """
27- self.layer.switchDbUser('postgres')
28 super(TestPOTMsgSetMergingAndTranslations, self).setUp(
29- user='mark@example.com')
30+ user=ADMIN_EMAIL)
31+ self.becomeDbUser('postgres')
32 super(TestPOTMsgSetMergingAndTranslations, self).setUpProduct()
33
34 def test_sharingDivergedMessages(self):
35@@ -374,9 +375,8 @@
36 layer = LaunchpadZopelessLayer
37
38 def setUp(self):
39- self.layer.switchDbUser('postgres')
40- super(TestTranslationMessageNonMerging, self).setUp(
41- user='mark@example.com')
42+ super(TestTranslationMessageNonMerging, self).setUp(user=ADMIN_EMAIL)
43+ self.becomeDbUser('postgres')
44 super(TestTranslationMessageNonMerging, self).setUpProduct()
45
46 def test_MessagesAreNotSharedAcrossPOTMsgSets(self):
47@@ -402,9 +402,8 @@
48 layer = LaunchpadZopelessLayer
49
50 def setUp(self):
51- self.layer.switchDbUser('postgres')
52- super(TestTranslationMessageMerging, self).setUp(
53- user='mark@example.com')
54+ super(TestTranslationMessageMerging, self).setUp(user=ADMIN_EMAIL)
55+ self.becomeDbUser('postgres')
56 super(TestTranslationMessageMerging, self).setUpProduct()
57
58 def test_messagesCanStayDiverged(self):
59@@ -565,8 +564,8 @@
60 layer = LaunchpadZopelessLayer
61
62 def setUp(self):
63- self.layer.switchDbUser('postgres')
64- super(TestRemoveDuplicates, self).setUp(user='mark@example.com')
65+ super(TestRemoveDuplicates, self).setUp(user=ADMIN_EMAIL)
66+ self.becomeDbUser('postgres')
67 super(TestRemoveDuplicates, self).setUpProduct()
68
69 def test_duplicatesAreCleanedUp(self):
70@@ -735,8 +734,8 @@
71 layer = LaunchpadZopelessLayer
72
73 def setUp(self):
74- self.layer.switchDbUser('postgres')
75 super(TestSharingMigrationPerformance, self).setUp()
76+ self.becomeDbUser('postgres')
77 super(TestSharingMigrationPerformance, self).setUpProduct()
78
79 def _flushDbObjects(self):