Merge lp:~stub/launchpad/testsuite into lp:launchpad

Proposed by Stuart Bishop on 2010-04-13
Status: Merged
Approved by: Michael Hudson-Doyle on 2010-04-13
Approved revision: 7202
Merged at revision: not available
Proposed branch: lp:~stub/launchpad/testsuite
Merge into: lp:launchpad
Diff against target: 742 lines (+63/-87)
24 files modified
lib/canonical/launchpad/mail/tests/test_incoming.py (+2/-0)
lib/canonical/launchpad/scripts/tests/test_garbo.py (+2/-13)
lib/lp/app/browser/tests/test_launchpadroot.py (+2/-2)
lib/lp/archiveuploader/tests/test_ppauploadprocessor.py (+3/-2)
lib/lp/bugs/doc/bug-heat.txt (+1/-0)
lib/lp/bugs/doc/bugtask-search.txt (+3/-2)
lib/lp/bugs/stories/patches-view/patches-view.txt (+15/-1)
lib/lp/bugs/tests/test_apportjob.py (+1/-0)
lib/lp/bugs/tests/test_bugs_webservice.py (+1/-1)
lib/lp/bugs/tests/test_bugwatch.py (+1/-1)
lib/lp/code/browser/tests/test_sourcepackagerecipe.py (+1/-1)
lib/lp/code/stories/branches/xx-source-package-branches-listing.txt (+3/-0)
lib/lp/code/stories/webservice/xx-branchmergeproposal.txt (+1/-0)
lib/lp/registry/browser/tests/peoplemerge-views.txt (+2/-0)
lib/lp/registry/browser/tests/product-views.txt (+1/-0)
lib/lp/registry/browser/tests/test_person_view.py (+3/-1)
lib/lp/registry/doc/distroseries.txt (+1/-0)
lib/lp/registry/doc/mailinglist-subscriptions.txt (+1/-0)
lib/lp/registry/doc/private-team-roles.txt (+1/-1)
lib/lp/testing/factory.py (+7/-61)
lib/lp/translations/doc/poexportqueue-replication-lag.txt (+1/-1)
lib/lp/translations/tests/test_potmsgset.py (+5/-0)
lib/lp/translations/tests/test_suggestions.py (+3/-0)
lib/lp/translations/tests/test_translations_to_review.py (+2/-0)
To merge this branch: bzr merge lp:~stub/launchpad/testsuite
Reviewer Review Type Date Requested Status
Michael Hudson-Doyle 2010-04-13 Approve on 2010-04-13
Review via email: mp+23282@code.launchpad.net

Description of the Change

Remove commit() statements from the testsuite's factory.py, as they are no longer necessary now the authdb replication set has been collapsed back into the lpmain replication set.

This broke a number of tests that needed fixing. The fixes are mainly mechanical - adding an explicit commit() after a factory call. Some tests need multiple commits, even when not dealing with external processes such as the Librarian, as they are relying on objects being created with distinct timestamps and committing them all in the same transaction will give them identical timestamps.

To post a comment you must log in.
Michael Hudson-Doyle (mwhudson) wrote :

It would be nice to know why the commit()s you're inserting are needed where its not obvious, but I can see why that would be exceedingly tedious to do. Otherwise, yay!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/launchpad/mail/tests/test_incoming.py'
2--- lib/canonical/launchpad/mail/tests/test_incoming.py 2009-08-05 13:59:44 +0000
3+++ lib/canonical/launchpad/mail/tests/test_incoming.py 2010-04-13 02:02:49 +0000
4@@ -3,6 +3,7 @@
5
6 import unittest
7
8+import transaction
9 from zope.testing.doctest import DocTestSuite
10
11 from canonical.launchpad.mail.incoming import handleMail, MailErrorUtility
12@@ -22,6 +23,7 @@
13 It should produce a message explaining to the user what went wrong.
14 """
15 person = self.factory.makePerson()
16+ transaction.commit()
17 email_address = person.preferredemail.email
18 invalid_body = (
19 '-----BEGIN PGP SIGNED MESSAGE-----\n'
20
21=== modified file 'lib/canonical/launchpad/scripts/tests/test_garbo.py'
22--- lib/canonical/launchpad/scripts/tests/test_garbo.py 2010-04-08 08:55:10 +0000
23+++ lib/canonical/launchpad/scripts/tests/test_garbo.py 2010-04-13 02:02:49 +0000
24@@ -76,6 +76,7 @@
25 self.runHourly()
26
27 def runDaily(self, maximum_chunk_size=2, test_args=()):
28+ transaction.commit()
29 LaunchpadZopelessLayer.switchDbUser('garbo_daily')
30 collector = DailyDatabaseGarbageCollector(test_args=list(test_args))
31 collector._maximum_chunk_size = maximum_chunk_size
32@@ -292,7 +293,6 @@
33 # Validating an email address creates a linkage.
34 person2.validateAndEnsurePreferredEmail(person2.guessedemails[0])
35 self.assertEqual(rev2.revision_author.person, None)
36- transaction.commit()
37
38 self.runDaily()
39 LaunchpadZopelessLayer.switchDbUser('testadmin')
40@@ -301,7 +301,6 @@
41 # Creating a person for an existing account creates a linkage.
42 person3 = account3.createPerson(PersonCreationRationale.UNKNOWN)
43 self.assertEqual(rev3.revision_author.person, None)
44- transaction.commit()
45
46 self.runDaily()
47 LaunchpadZopelessLayer.switchDbUser('testadmin')
48@@ -339,7 +338,6 @@
49 # Validating an email address creates a linkage.
50 person2.validateAndEnsurePreferredEmail(person2.guessedemails[0])
51 self.assertEqual(sub2.owner, None)
52- transaction.commit()
53
54 self.runDaily()
55 LaunchpadZopelessLayer.switchDbUser('testadmin')
56@@ -348,7 +346,6 @@
57 # Creating a person for an existing account creates a linkage.
58 person3 = account3.createPerson(PersonCreationRationale.UNKNOWN)
59 self.assertEqual(sub3.owner, None)
60- transaction.commit()
61
62 self.runDaily()
63 LaunchpadZopelessLayer.switchDbUser('testadmin')
64@@ -362,7 +359,6 @@
65 email = self.factory.makeEmail('secondary@example.org', person)
66 transaction.commit()
67 mailing_list.subscribe(person, email)
68- transaction.commit()
69
70 # User remains subscribed if we run the garbage collector.
71 self.runDaily()
72@@ -372,7 +368,6 @@
73 # garbage collector removes the subscription.
74 LaunchpadZopelessLayer.switchDbUser('testadmin')
75 Store.of(email).remove(email)
76- transaction.commit()
77 self.runDaily()
78 self.assertEqual(mailing_list.getSubscription(person), None)
79
80@@ -390,7 +385,6 @@
81 person_old = self.factory.makePerson(name='test-unlinked-person-old')
82 removeSecurityProxy(person_old).datecreated = datetime(
83 2008, 01, 01, tzinfo=UTC)
84- transaction.commit()
85
86 # Normally, the garbage collector will do nothing because the
87 # PersonPruner is experimental
88@@ -453,7 +447,6 @@
89 self.assertEqual(num_new, 8)
90
91 # Run the garbage collector.
92- transaction.commit()
93 self.runDaily()
94
95 # We should have 9 BugNotifications left.
96@@ -487,8 +480,6 @@
97 EmailAddress, person=person).any()
98 person.accountID = -1
99
100- transaction.commit()
101-
102 # Run the garbage collector. We should get two ERROR reports
103 # about the corrupt data.
104 collector = self.runDaily()
105@@ -520,7 +511,7 @@
106 db_branch = self.factory.makeAnyBranch()
107 db_branch.branch_format = BranchFormat.BZR_BRANCH_5
108 db_branch.repository_format = RepositoryFormat.BZR_KNIT_1
109-
110+ Store.of(db_branch).flush()
111 branch_job = BranchUpgradeJob.create(db_branch)
112 branch_job.job.date_finished = THIRTY_DAYS_AGO
113 job_id = branch_job.job.id
114@@ -530,7 +521,6 @@
115 BranchJob,
116 BranchJob.branch == db_branch.id).count(),
117 1)
118- transaction.commit()
119
120 collector = self.runDaily()
121
122@@ -561,7 +551,6 @@
123 repository_format=RepositoryFormat.BZR_KNIT_1)
124 branch_job2 = BranchUpgradeJob.create(db_branch2)
125 job_id_newer = branch_job2.job.id
126- transaction.commit()
127
128 collector = self.runDaily()
129
130
131=== modified file 'lib/lp/app/browser/tests/test_launchpadroot.py'
132--- lib/lp/app/browser/tests/test_launchpadroot.py 2010-01-13 02:11:09 +0000
133+++ lib/lp/app/browser/tests/test_launchpadroot.py 2010-04-13 02:02:49 +0000
134@@ -36,7 +36,7 @@
135 def setUpRegistryExpert(self):
136 """Create a registry expert and logs in as them."""
137 login_person(self.admin)
138- self.expert = self.factory.makePersonNoCommit()
139+ self.expert = self.factory.makePerson()
140 getUtility(ILaunchpadCelebrities).registry_experts.addMember(
141 self.expert, self.admin)
142 login_person(self.expert)
143@@ -46,7 +46,7 @@
144 "Anonymous user shouldn't have launchpad.Edit on ILaunchpadRoot")
145
146 def test_regular_user_cannot_edit(self):
147- login_person(self.factory.makePersonNoCommit())
148+ login_person(self.factory.makePerson())
149 self.failIf(check_permission('launchpad.Edit', self.root),
150 "Regular users shouldn't have launchpad.Edit on ILaunchpadRoot")
151
152
153=== modified file 'lib/lp/archiveuploader/tests/test_ppauploadprocessor.py'
154--- lib/lp/archiveuploader/tests/test_ppauploadprocessor.py 2010-01-07 06:29:36 +0000
155+++ lib/lp/archiveuploader/tests/test_ppauploadprocessor.py 2010-04-13 02:02:49 +0000
156@@ -9,12 +9,12 @@
157
158 __metaclass__ = type
159
160+from email import message_from_string
161 import os
162 import shutil
163 import unittest
164
165-from email import message_from_string
166-
167+import transaction
168 from zope.component import getUtility
169 from zope.security.proxy import removeSecurityProxy
170
171@@ -488,6 +488,7 @@
172 email = "contact@example.com"
173 name = "Team"
174 team = self.factory.makeTeam(email=email, displayname=name)
175+ transaction.commit()
176 name12 = getUtility(IPersonSet).getByName("name12")
177 cprov.archive.newComponentUploader(name12, "main")
178 cprov.archive.newComponentUploader(team, "main")
179
180=== modified file 'lib/lp/bugs/doc/bug-heat.txt'
181--- lib/lp/bugs/doc/bug-heat.txt 2010-03-05 10:06:40 +0000
182+++ lib/lp/bugs/doc/bug-heat.txt 2010-04-13 02:02:49 +0000
183@@ -180,6 +180,7 @@
184 target.
185
186 >>> another_product = factory.makeProduct()
187+ >>> transaction.commit()
188 >>> bug.bugtasks[0].transitionToTarget(another_product)
189 >>> print another_product.max_bug_heat
190 123
191
192=== modified file 'lib/lp/bugs/doc/bugtask-search.txt'
193--- lib/lp/bugs/doc/bugtask-search.txt 2010-02-27 20:20:03 +0000
194+++ lib/lp/bugs/doc/bugtask-search.txt 2010-04-13 02:02:49 +0000
195@@ -709,7 +709,7 @@
196 >>> import pytz
197 >>> from datetime import datetime, timedelta
198 >>> from canonical.launchpad.searchbuilder import greater_than
199- >>> product = factory.makeProductNoCommit()
200+ >>> product = factory.makeProduct()
201 >>> utc_now = datetime(2008, 9, 4, 12, 0, 0, tzinfo=pytz.timezone('UTC'))
202 >>> not_closed_bug = factory.makeBug(product=product, title="Not closed")
203 >>> bug_closed_a_day_ago = factory.makeBug(
204@@ -739,7 +739,7 @@
205 >>> from canonical.launchpad.interfaces import (
206 ... BugAttachmentType, IBugAttachmentSet, ILibraryFileAliasSet,
207 ... IMessageSet)
208- >>> product = factory.makeProductNoCommit()
209+ >>> product = factory.makeProduct()
210 >>> patch_bug = factory.makeBug(
211 ... product=product)
212 >>> filecontent = 'Some diff data'
213@@ -1120,6 +1120,7 @@
214
215 >>> patch_attachment_bug_2 = factory.makeBugAttachment(
216 ... bug=bug_two, is_patch=True)
217+ >>> transaction.commit()
218 >>> patch_attachment_bug_10 = factory.makeBugAttachment(
219 ... bug=bug_ten, is_patch=True)
220 >>> params = BugTaskSearchParams(
221
222=== modified file 'lib/lp/bugs/stories/patches-view/patches-view.txt'
223--- lib/lp/bugs/stories/patches-view/patches-view.txt 2010-03-15 03:30:09 +0000
224+++ lib/lp/bugs/stories/patches-view/patches-view.txt 2010-04-13 02:02:49 +0000
225@@ -10,6 +10,7 @@
226 >>> patchy_product = factory.doAsUser(
227 ... 'foo.bar@canonical.com', factory.makeProduct,
228 ... name='patchy-product-1', displayname="Patchy 1")
229+ >>> transaction.commit()
230
231 We don't see any patches when we open the patches view.
232
233@@ -34,15 +35,18 @@
234 ... title, product, importance=BugTaskImportance.UNDECIDED,
235 ... status=BugTaskStatus.NEW):
236 ... bug = factory.makeBug(title=title, product=product)
237+ ... transaction.commit()
238 ... bug.default_bugtask.transitionToImportance(
239 ... importance, product.owner)
240 ... bug.default_bugtask.transitionToStatus(
241 ... status, product.owner)
242+ ... transaction.commit()
243 ... return bug
244
245 >>> bug_a = factory.doAsUser(
246 ... 'foo.bar@canonical.com', make_bug,
247 ... title="bug_a title", product=patchy_product)
248+ >>> transaction.commit()
249 >>> anon_browser.open(
250 ... 'http://bugs.launchpad.dev/patchy-product-1/+patches')
251 >>> show_patches_view(anon_browser.contents)
252@@ -54,6 +58,7 @@
253 >>> factory.doAsUser('foo.bar@canonical.com', factory.makeBugAttachment,
254 ... bug=bug_a, is_patch=False)
255 <BugAttachment at...
256+ >>> transaction.commit()
257 >>> anon_browser.open('http://bugs.launchpad.dev/patchy-product-1/+patches')
258 >>> show_patches_view(anon_browser.contents)
259 There are no patches associated with Patchy 1 at this time.
260@@ -64,12 +69,14 @@
261 >>> patch_submitter = factory.doAsUser(
262 ... 'foo.bar@canonical.com', factory.makePerson,
263 ... name="patchy-person", displayname="Patchy Person")
264+ >>> transaction.commit()
265 >>> factory.doAsUser(
266 ... 'foo.bar@canonical.com', factory.makeBugAttachment,
267 ... comment="comment about patch a",
268 ... filename="patch_a.diff", owner=patch_submitter,
269 ... description="description of patch a", bug=bug_a, is_patch=True)
270 <BugAttachment at...
271+ >>> transaction.commit()
272 >>> anon_browser.open(
273 ... 'http://bugs.launchpad.dev/patchy-product-1/+patches')
274 >>> show_patches_view(anon_browser.contents)
275@@ -109,41 +116,48 @@
276 ... filename="patch_b.diff", owner=patch_submitter,
277 ... description="description of patch b", bug=bug_b, is_patch=True)
278 <BugAttachment at...
279+ >>> transaction.commit()
280 >>> factory.doAsUser(
281 ... 'foo.bar@canonical.com', factory.makeBugAttachment,
282 ... comment="comment about patch c",
283 ... filename="patch_c.diff", owner=patch_submitter,
284 ... description="description of patch c", bug=bug_b, is_patch=True)
285 <BugAttachment at...
286+ >>> transaction.commit()
287 >>> factory.doAsUser(
288 ... 'foo.bar@canonical.com', factory.makeBugAttachment,
289 ... bug=bug_c, is_patch=False)
290 <BugAttachment at...
291+ >>> transaction.commit()
292 >>> factory.doAsUser(
293 ... 'foo.bar@canonical.com', factory.makeBugAttachment,
294 ... comment="comment about patch d",
295 ... filename="patch_d.diff", owner=patch_submitter,
296 ... description="description of patch d", bug=bug_c, is_patch=True)
297 <BugAttachment at...
298+ >>> transaction.commit()
299 >>> factory.doAsUser(
300 ... 'foo.bar@canonical.com', factory.makeBugAttachment,
301 ... comment="comment about patch e",
302 ... filename="patch_e.diff", owner=patch_submitter,
303 ... description="description of patch e", bug=bug_c, is_patch=True)
304 <BugAttachment at...
305+ >>> transaction.commit()
306 >>> factory.doAsUser(
307 ... 'foo.bar@canonical.com', factory.makeBugAttachment,
308 ... comment="comment about patch f",
309 ... filename="patch_f.diff", owner=patch_submitter,
310 ... description="description of patch f", bug=bug_c, is_patch=True)
311 <BugAttachment at...
312+ >>> transaction.commit()
313 >>> factory.doAsUser(
314 ... 'foo.bar@canonical.com', factory.makeBugAttachment,
315 ... comment="comment about patch g",
316 ... filename="patch_g.diff", owner=patch_submitter,
317 ... description="description of patch g", bug=bug_d, is_patch=True)
318 <BugAttachment at...
319-
320+ >>> transaction.commit()
321+
322 ...the youngest patch on each bug is visible in the patch report
323 (except for bugs in "Fix Released" state, which aren't shown):
324
325
326=== modified file 'lib/lp/bugs/tests/test_apportjob.py'
327--- lib/lp/bugs/tests/test_apportjob.py 2010-02-26 11:48:40 +0000
328+++ lib/lp/bugs/tests/test_apportjob.py 2010-04-13 02:02:49 +0000
329@@ -85,6 +85,7 @@
330 blob_data = blob_file.read()
331
332 self.blob = self.factory.makeBlob(blob_data)
333+ transaction.commit() # We need the blob available from the Librarian.
334
335 def _assertFileBugDataMatchesDict(self, filebug_data, data_dict):
336 """Asser that the data in a FileBugData object matches a dict."""
337
338=== modified file 'lib/lp/bugs/tests/test_bugs_webservice.py'
339--- lib/lp/bugs/tests/test_bugs_webservice.py 2010-03-10 11:32:30 +0000
340+++ lib/lp/bugs/tests/test_bugs_webservice.py 2010-04-13 02:02:49 +0000
341@@ -192,7 +192,7 @@
342 try:
343 login('foo.bar@canonical.com')
344 for count in range(snapshot.HARD_LIMIT_FOR_SNAPSHOT + 1):
345- person = self.factory.makePersonNoCommit()
346+ person = self.factory.makePerson()
347 bug.subscribe(person, person)
348 logout()
349 response = webservice.named_post(
350
351=== modified file 'lib/lp/bugs/tests/test_bugwatch.py'
352--- lib/lp/bugs/tests/test_bugwatch.py 2010-04-09 20:09:19 +0000
353+++ lib/lp/bugs/tests/test_bugwatch.py 2010-04-13 02:02:49 +0000
354@@ -339,7 +339,7 @@
355 # The bugtasks_to_update property should yield the linked bug
356 # tasks which are not conjoined and for which the bug is not a
357 # duplicate.
358- product = self.factory.makeProductNoCommit()
359+ product = self.factory.makeProduct()
360 bug = self.factory.makeBug(product=product, owner=product.owner)
361 product_task = bug.getBugTask(product)
362 watch = self.factory.makeBugWatch(bug=bug)
363
364=== modified file 'lib/lp/code/browser/tests/test_sourcepackagerecipe.py'
365--- lib/lp/code/browser/tests/test_sourcepackagerecipe.py 2010-03-30 04:56:42 +0000
366+++ lib/lp/code/browser/tests/test_sourcepackagerecipe.py 2010-04-13 02:02:49 +0000
367@@ -26,7 +26,7 @@
368 layer = DatabaseFunctionalLayer
369
370 def makeRecipe(self):
371- chef = self.factory.makePersonNoCommit(displayname='Master Chef',
372+ chef = self.factory.makePerson(displayname='Master Chef',
373 name='chef')
374 chocolate = self.factory.makeProduct(name='chocolate')
375 cake_branch = self.factory.makeProductBranch(
376
377=== modified file 'lib/lp/code/stories/branches/xx-source-package-branches-listing.txt'
378--- lib/lp/code/stories/branches/xx-source-package-branches-listing.txt 2009-09-17 03:44:41 +0000
379+++ lib/lp/code/stories/branches/xx-source-package-branches-listing.txt 2010-04-13 02:02:49 +0000
380@@ -18,9 +18,11 @@
381 >>> branch1 = factory.makePackageBranch(
382 ... sourcepackage=source_package,
383 ... owner=factory.makePerson(name='owner1'), name='branch1')
384+ >>> transaction.commit()
385 >>> branch2 = factory.makePackageBranch(
386 ... sourcepackage=source_package,
387 ... owner=factory.makePerson(name='owner2'), name='branch2')
388+ >>> transaction.commit()
389 >>> source_package_url = canonical_url(source_package, rootsite='code')
390 >>> logout()
391
392@@ -56,6 +58,7 @@
393 ... sourcepackage=source_package, owner=branch1.owner, name="branch3")
394 >>> distro_source_package = factory.makeDistributionSourcePackage(
395 ... distribution=distro, sourcepackagename=branch1.sourcepackagename)
396+ >>> transaction.commit()
397 >>> distro_source_package_listing = canonical_url(
398 ... distro_source_package, view_name="+branches")
399 >>> logout()
400
401=== modified file 'lib/lp/code/stories/webservice/xx-branchmergeproposal.txt'
402--- lib/lp/code/stories/webservice/xx-branchmergeproposal.txt 2010-03-10 23:40:02 +0000
403+++ lib/lp/code/stories/webservice/xx-branchmergeproposal.txt 2010-04-13 02:02:49 +0000
404@@ -125,6 +125,7 @@
405 ... subject='Not really', body='This is mediocre work.',
406 ... vote=CodeReviewVote.ABSTAIN, parent=comment,
407 ... merge_proposal=fixit_proposal)
408+ >>> transaction.commit()
409
410 >>> proposal_url = fix_url(canonical_url(
411 ... fixit_proposal, request=request, rootsite='api'))
412
413=== modified file 'lib/lp/registry/browser/tests/peoplemerge-views.txt'
414--- lib/lp/registry/browser/tests/peoplemerge-views.txt 2010-01-19 23:57:36 +0000
415+++ lib/lp/registry/browser/tests/peoplemerge-views.txt 2010-04-13 02:02:49 +0000
416@@ -47,6 +47,7 @@
417 >>> parent_team = factory.makeTeam()
418 >>> child_team = factory.makeTeam(name='child-team')
419 >>> random_team = factory.makeTeam()
420+ >>> transaction.commit()
421 >>> login('foo.bar@canonical.com')
422 >>> ignored = parent_team.addMember(
423 ... child_team, reviewer=parent_team.teamowner, force_team_add=True)
424@@ -211,6 +212,7 @@
425 the team that the merge operation is performed with.
426
427 >>> deletable_team = factory.makeTeam(owner=team_owner, name='deletable')
428+ >>> transaction.commit()
429 >>> form = {
430 ... 'field.target_person': 'rosetta-admins',
431 ... 'field.dupe_person': 'landscape-developers',
432
433=== modified file 'lib/lp/registry/browser/tests/product-views.txt'
434--- lib/lp/registry/browser/tests/product-views.txt 2010-03-06 12:16:29 +0000
435+++ lib/lp/registry/browser/tests/product-views.txt 2010-04-13 02:02:49 +0000
436@@ -488,6 +488,7 @@
437 the user to make the connection.
438
439 >>> product = factory.makeProduct(name="bingo")
440+ >>> transaction.commit()
441 >>> login_person(product.owner)
442 >>> view = create_initialized_view(
443 ... product, name="+portlet-packages",
444
445=== modified file 'lib/lp/registry/browser/tests/test_person_view.py'
446--- lib/lp/registry/browser/tests/test_person_view.py 2009-10-30 14:05:09 +0000
447+++ lib/lp/registry/browser/tests/test_person_view.py 2010-04-13 02:02:49 +0000
448@@ -5,6 +5,7 @@
449
450 import unittest
451
452+import transaction
453 from zope.component import getUtility
454
455 from canonical.launchpad.ftests import ANONYMOUS, login
456@@ -25,6 +26,7 @@
457 TestCaseWithFactory.setUp(self)
458 person = self.factory.makePerson()
459 product = self.factory.makeProduct()
460+ transaction.commit()
461 self.view = PersonView(
462 person, LaunchpadTestRequest())
463 self._makeKarmaCache(
464@@ -66,7 +68,7 @@
465
466 # We must commit here so that the change is seen in other transactions
467 # (e.g. when the callsite issues a switchDbUser() after we return).
468- LaunchpadZopelessLayer.commit()
469+ transaction.commit()
470 return karmacache
471
472
473
474=== modified file 'lib/lp/registry/doc/distroseries.txt'
475--- lib/lp/registry/doc/distroseries.txt 2010-03-01 22:56:38 +0000
476+++ lib/lp/registry/doc/distroseries.txt 2010-04-13 02:02:49 +0000
477@@ -487,6 +487,7 @@
478 ... package = factory.makeSourcePackage(sourcepackagename=spn,
479 ... distroseries=distroseries)
480 ... package.setPackaging(productseries, product.owner)
481+ ... transaction.commit()
482
483
484 >>> pkgs = distroseries.getMostRecentlyLinkedPackagings()
485
486=== modified file 'lib/lp/registry/doc/mailinglist-subscriptions.txt'
487--- lib/lp/registry/doc/mailinglist-subscriptions.txt 2009-12-24 01:41:54 +0000
488+++ lib/lp/registry/doc/mailinglist-subscriptions.txt 2010-04-13 02:02:49 +0000
489@@ -1077,6 +1077,7 @@
490 >>> team_names.append(team_seven.name)
491
492 >>> sam = factory.makePersonByName('Samuel')
493+ >>> transaction.commit()
494
495 >>> list_seven.subscribe(sam)
496 >>> sorted(email.email for email in list_seven.getSubscribedAddresses())
497
498=== modified file 'lib/lp/registry/doc/private-team-roles.txt'
499--- lib/lp/registry/doc/private-team-roles.txt 2010-02-11 19:17:52 +0000
500+++ lib/lp/registry/doc/private-team-roles.txt 2010-04-13 02:02:49 +0000
501@@ -230,6 +230,7 @@
502 >>> subscription = private_archive.newSubscription(
503 ... subscriber=another_priv_team,
504 ... registrant=team_owner)
505+ >>> transaction.commit()
506
507 Private Membership Teams cannot subscribe to private PPAs.
508
509@@ -240,7 +241,6 @@
510 PrivatePersonLinkageError: Cannot link person
511 (name=private-membership-team, visibility=PRIVATE_MEMBERSHIP) to
512 <...ArchiveSubscriber object at...
513- >>> import transaction
514 >>> transaction.abort()
515
516
517
518=== modified file 'lib/lp/testing/factory.py'
519--- lib/lp/testing/factory.py 2010-04-09 02:08:39 +0000
520+++ lib/lp/testing/factory.py 2010-04-13 02:02:49 +0000
521@@ -307,7 +307,6 @@
522 login(user)
523 try:
524 result = factory_method(**factory_args)
525- transaction.commit()
526 finally:
527 logout()
528 return result
529@@ -328,13 +327,8 @@
530
531 def makeAccount(self, displayname, email=None, password=None,
532 status=AccountStatus.ACTIVE,
533- rationale=AccountCreationRationale.UNKNOWN,
534- commit=True):
535- """Create and return a new Account.
536-
537- If commit is True, we do a transaction.commit() at the end so that the
538- newly created objects can be seen in other stores as well.
539- """
540+ rationale=AccountCreationRationale.UNKNOWN):
541+ """Create and return a new Account."""
542 account = getUtility(IAccountSet).new(
543 rationale, displayname, password=password)
544 removeSecurityProxy(account).status = status
545@@ -345,24 +339,8 @@
546 email_status = EmailAddressStatus.NEW
547 email = self.makeEmail(
548 email, person=None, account=account, email_status=email_status)
549- if commit:
550- transaction.commit()
551 return account
552
553- def makePerson(self, *args, **kwargs):
554- """As makePersonNoCommit, except with an implicit transaction commit.
555-
556- makePersonNoCommit makes changes to two seperate database connections,
557- and the returned Person can have odd behavior until a commit is
558- made. For example, person.preferredemail will be None as this
559- is looking in the main Store for email address details, not the
560- email address master Store (the auth Store).
561- """
562- person = self.makePersonNoCommit(*args, **kwargs)
563- transaction.commit()
564- self._stuff_preferredemail_cache(person)
565- return person
566-
567 def makeGPGKey(self, owner):
568 """Give 'owner' a crappy GPG key for the purposes of testing."""
569 key_id = self.getUniqueHexString(digits=8).upper()
570@@ -376,20 +354,7 @@
571 active=True,
572 can_encrypt=False)
573
574- def _stuff_preferredemail_cache(self, person):
575- """Stuff the preferredemail cache.
576-
577- cachedproperty does not get reset across transactions,
578- so person.preferredemail can contain a bogus value even after
579- a commit, despite all changes now being available in the main
580- store.
581- """
582- naked_person = removeSecurityProxy(person)
583- naked_person._preferredemail_cached = Store.of(person).find(
584- EmailAddress, personID=person.id,
585- status=EmailAddressStatus.PREFERRED).one()
586-
587- def makePersonNoCommit(
588+ def makePerson(
589 self, email=None, name=None, password=None,
590 email_address_status=None, hide_email_addresses=False,
591 displayname=None, time_zone=None, latitude=None, longitude=None):
592@@ -501,8 +466,6 @@
593 getUtility(IEmailAddressSet).new(
594 alternative_address, person, EmailAddressStatus.VALIDATED,
595 account)
596- transaction.commit()
597- self._stuff_preferredemail_cache(person)
598 return person
599
600 def makeEmail(self, address, person, account=None, email_status=None):
601@@ -568,8 +531,6 @@
602 if email is not None:
603 team.setContactAddress(
604 getUtility(IEmailAddressSet).new(email, team))
605- transaction.commit()
606- self._stuff_preferredemail_cache(team)
607 return team
608
609 def makePoll(self, team, name, title, proposition):
610@@ -680,24 +641,14 @@
611 signature_content=signature_content,
612 description=description)
613
614- def makeProduct(self, *args, **kwargs):
615- """As makeProductNoCommit with an explicit transaction commit.
616-
617- This ensures that generated owners and registrants are fully
618- flushed and available from all Stores.
619- """
620- product = self.makeProductNoCommit(*args, **kwargs)
621- transaction.commit()
622- return product
623-
624- def makeProductNoCommit(
625+ def makeProduct(
626 self, name=None, project=None, displayname=None,
627 licenses=None, owner=None, registrant=None,
628 title=None, summary=None, official_malone=None,
629 official_rosetta=None):
630 """Create and return a new, arbitrary Product."""
631 if owner is None:
632- owner = self.makePersonNoCommit()
633+ owner = self.makePerson()
634 if name is None:
635 name = self.getUniqueString('product-name')
636 if displayname is None:
637@@ -1128,9 +1079,9 @@
638 to this URL.
639 """
640 if product is None:
641- product = self.makeProductNoCommit()
642+ product = self.makeProduct()
643 if owner is None:
644- owner = self.makePersonNoCommit()
645+ owner = self.makePerson()
646 if title is None:
647 title = self.getUniqueString()
648 if comment is None:
649@@ -1529,10 +1480,6 @@
650 merge_proposal=None):
651 if sender is None:
652 sender = self.makePerson()
653- # Until we commit, sender.preferredemail returns None
654- # because the email address changes pending in the auth Store
655- # are not available via the main Store.
656- transaction.commit()
657 if subject is None:
658 subject = self.getUniqueString('subject')
659 if body is None:
660@@ -2441,6 +2388,5 @@
661 if blob is None:
662 blob = self.getUniqueString()
663 new_uuid = getUtility(ITemporaryStorageManager).new(blob, expires)
664- transaction.commit()
665
666 return getUtility(ITemporaryStorageManager).fetch(new_uuid)
667
668=== modified file 'lib/lp/translations/doc/poexportqueue-replication-lag.txt'
669--- lib/lp/translations/doc/poexportqueue-replication-lag.txt 2010-03-05 17:35:45 +0000
670+++ lib/lp/translations/doc/poexportqueue-replication-lag.txt 2010-04-13 02:02:49 +0000
671@@ -21,7 +21,7 @@
672
673 We have somebody making an export request.
674
675- >>> requester = factory.makePersonNoCommit(
676+ >>> requester = factory.makePerson(
677 ... email='punter@example.com', name='punter')
678
679 >>> template1 = factory.makePOTemplate()
680
681=== modified file 'lib/lp/translations/tests/test_potmsgset.py'
682--- lib/lp/translations/tests/test_potmsgset.py 2010-03-06 06:21:04 +0000
683+++ lib/lp/translations/tests/test_potmsgset.py 2010-04-13 02:02:49 +0000
684@@ -833,19 +833,24 @@
685 def test_dismiss_empty_translation(self):
686 # Set order of creation and review.
687 self._setDateCreated(self.suggestion1)
688+ transaction.commit()
689 self._setDateCreated(self.suggestion2)
690+ transaction.commit()
691 # Make the translation a suggestion, too.
692 suggestion3 = self.translation
693 suggestion3.is_current = False
694 self._setDateCreated(suggestion3)
695+ transaction.commit()
696 # All suggestions are visible.
697 self.assertContentEqual(
698 [self.suggestion1, self.suggestion2, suggestion3],
699 self.potmsgset.getLocalTranslationMessages(
700 self.potemplate, self.pofile.language))
701+ transaction.commit()
702 # Dismiss suggestions, leaving the translation empty.
703 self.potmsgset.dismissAllSuggestions(
704 self.pofile, self.factory.makePerson(), self.now())
705+ transaction.commit()
706 current = self.potmsgset.getCurrentTranslationMessage(
707 self.potemplate, self.pofile.language)
708 self.assertNotEqual(None, current)
709
710=== modified file 'lib/lp/translations/tests/test_suggestions.py'
711--- lib/lp/translations/tests/test_suggestions.py 2010-03-06 06:21:04 +0000
712+++ lib/lp/translations/tests/test_suggestions.py 2010-04-13 02:02:49 +0000
713@@ -159,6 +159,9 @@
714 oof_potmsgset = self.factory.makePOTMsgSet(
715 oof_template, singular=text)
716 oof_potmsgset.setSequence(oof_template, 1)
717+ from storm.store import Store
718+ Store.of(oof_template).flush()
719+ transaction.commit()
720 suggestions = oof_potmsgset.getExternallyUsedTranslationMessages(
721 self.nl)
722 self.assertEquals(len(suggestions), 1)
723
724=== modified file 'lib/lp/translations/tests/test_translations_to_review.py'
725--- lib/lp/translations/tests/test_translations_to_review.py 2009-11-13 12:39:11 +0000
726+++ lib/lp/translations/tests/test_translations_to_review.py 2010-04-13 02:02:49 +0000
727@@ -9,6 +9,7 @@
728 from pytz import timezone
729 from unittest import TestLoader
730
731+import transaction
732 from zope.security.proxy import removeSecurityProxy
733
734 from lp.translations.interfaces.translationsperson import ITranslationsPerson
735@@ -62,6 +63,7 @@
736 self.distribution.translation_focus = self.distroseries
737 self.sourcepackagename = self.factory.makeSourcePackageName()
738 self.supercontext = self.distribution
739+ transaction.commit()
740
741 self.supercontext.translationgroup = self.translationgroup
742 self.supercontext.official_rosetta = True