Merge lp:~adeuring/launchpad/security-guarded-test-object-factory-1 into lp:launchpad
- security-guarded-test-object-factory-1
- Merge into devel
Status: | Merged |
---|---|
Approved by: | Jeroen T. Vermeulen |
Approved revision: | no longer in the source branch. |
Merged at revision: | 11208 |
Proposed branch: | lp:~adeuring/launchpad/security-guarded-test-object-factory-1 |
Merge into: | lp:launchpad |
Diff against target: |
852 lines (+251/-48) 20 files modified
lib/lp/code/browser/tests/test_branchlisting.py (+4/-2) lib/lp/code/browser/tests/test_sourcepackagerecipe.py (+12/-5) lib/lp/code/browser/tests/test_sourcepackagerecipebuild.py (+4/-1) lib/lp/code/model/tests/test_branch.py (+4/-1) lib/lp/code/model/tests/test_linkedbranch.py (+7/-2) lib/lp/code/model/tests/test_sourcepackagerecipebuild.py (+5/-2) lib/lp/registry/browser/tests/distroseries-views.txt (+1/-1) lib/lp/registry/browser/tests/milestone-views.txt (+5/-1) lib/lp/registry/browser/tests/productseries-views.txt (+6/-2) lib/lp/registry/stories/webservice/xx-project-registry.txt (+4/-2) lib/lp/registry/tests/test_distroseries.py (+15/-6) lib/lp/registry/tests/test_sourcepackage.py (+9/-2) lib/lp/soyuz/browser/tests/test_distrosourcepackagerelease.py (+7/-1) lib/lp/soyuz/browser/tests/test_sourcepackagerelease.py (+11/-5) lib/lp/soyuz/tests/test_publishing.py (+9/-3) lib/lp/testing/factory.py (+82/-7) lib/lp/testing/tests/test_factory.py (+50/-0) lib/lp/translations/browser/tests/test_breadcrumbs.py (+3/-1) lib/lp/translations/doc/translations-export-to-branch.txt (+5/-1) lib/lp/translations/stories/buildfarm/xx-build-summary.txt (+8/-3) |
To merge this branch: | bzr merge lp:~adeuring/launchpad/security-guarded-test-object-factory-1 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jeroen T. Vermeulen (community) | code | Approve | |
Review via email: mp+30497@code.launchpad.net |
Commit message
Description of the change
While working together with Brian on another branch during the LP epic last week, I was bitten by the fact that we have still a number of methods in LaunchpadObject
Some time ago, Gavin noticed the same problem, IIRC for makePerson(); he also filed a bug that other methods still returned unproxied objects, and Salgado finally fixed that bug.
However, new methods obviously returning unproxied objects creeped into LaunchpadObject
The implementation is quite simple: I renamed LaunchpadObject
We have at present ca 20 methods which return, at least sometimes, unproxied objects. Fixing all these methods in one branch would result in a huge diff, so I fixed only two methods in this branch, makeDistroRelease() and makeProductSeri
My plan is to let guarded_method() raise an exception if it detects an unproxied object, once all existing factory methods return properly proxied objects. For now, it just print a warning to stderr.
The largest part of the diff is test fixes. I took the simple route: Just to remove the security proxy so that the affected tests pass again. I did not bother to check if this is reasonable in a given test -- doing so would simply have needed far too much time. Instead, I added a function remove_
Pre-/mid-imp discussions with Jeroen and Gary.
affected tests: Many, see the diff.
I also removed some lint in the files I touched, but some messages remain:
= Launchpad lint =
Checking for conflicts and issues in changed files.
Linting changed files:
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
./lib/lp/
83: want exceeds 78 characters.
./lib/lp/
570: source exceeds 78 characters.
1254: 'IRepresentatio
./lib/lp/
119: E302 expected 2 blank lines, found 1
./lib/lp/
27: E501 line too long (81 characters)
37: E501 line too long (86 characters)
45: E501 line too long (81 characters)
56: E501 line too long (86 characters)
64: E501 line too long (81 characters)
72: E501 line too long (82 characters)
81: E501 line too long (82 characters)
88: E501 line too long (81 characters)
138: E301 expected 1 blank line, found 0
152: E501 line too long (85 characters)
27: Line exceeds 78 characters.
37: Line exceeds 78 characters.
45: Line exceeds 78 characters.
56: Line exceeds 78 characters.
64: Line exceeds 78 characters.
72: Line exceeds 78 characters.
81: Line exceeds 78 characters.
88: Line exceeds 78 characters.
116: Line exceeds 78 characters.
133: Line exceeds 78 characters.
152: Line exceeds 78 characters.
./lib/lp/
0: narrative uses a moin header.
15: want exceeds 78 characters.
273: narrative uses a moin header.
301: narrative uses a moin header.
242: Could not compile:
./lib/lp/
0: narrative uses a moin header.
5: narrative uses a moin header.
64: narrative uses a moin header.
Preview Diff
1 | === modified file 'lib/lp/code/browser/tests/test_branchlisting.py' | |||
2 | --- lib/lp/code/browser/tests/test_branchlisting.py 2010-05-28 09:54:45 +0000 | |||
3 | +++ lib/lp/code/browser/tests/test_branchlisting.py 2010-07-22 13:01:10 +0000 | |||
4 | @@ -32,12 +32,14 @@ | |||
5 | 32 | from lp.testing import ( | 32 | from lp.testing import ( |
6 | 33 | BrowserTestCase, TestCase, TestCaseWithFactory, login_person, | 33 | BrowserTestCase, TestCase, TestCaseWithFactory, login_person, |
7 | 34 | person_logged_in, time_counter) | 34 | person_logged_in, time_counter) |
8 | 35 | from lp.testing.factory import remove_security_proxy_and_shout_at_engineer | ||
9 | 35 | from lp.testing.views import create_initialized_view | 36 | from lp.testing.views import create_initialized_view |
10 | 36 | from canonical.launchpad.testing.pages import extract_text, find_tag_by_id | 37 | from canonical.launchpad.testing.pages import extract_text, find_tag_by_id |
11 | 37 | from canonical.launchpad.webapp import canonical_url | 38 | from canonical.launchpad.webapp import canonical_url |
12 | 38 | from canonical.launchpad.webapp.servers import LaunchpadTestRequest | 39 | from canonical.launchpad.webapp.servers import LaunchpadTestRequest |
13 | 39 | from canonical.testing.layers import DatabaseFunctionalLayer | 40 | from canonical.testing.layers import DatabaseFunctionalLayer |
14 | 40 | 41 | ||
15 | 42 | |||
16 | 41 | class TestListingToSortOrder(TestCase): | 43 | class TestListingToSortOrder(TestCase): |
17 | 42 | """Tests for the BranchSet._listingSortToOrderBy static method. | 44 | """Tests for the BranchSet._listingSortToOrderBy static method. |
18 | 43 | 45 | ||
19 | @@ -60,6 +62,7 @@ | |||
20 | 60 | 62 | ||
21 | 61 | def assertSortsEqual(self, sort_one, sort_two): | 63 | def assertSortsEqual(self, sort_one, sort_two): |
22 | 62 | """Assert that one list of sort specs is equal to another.""" | 64 | """Assert that one list of sort specs is equal to another.""" |
23 | 65 | |||
24 | 63 | def sort_data(sort): | 66 | def sort_data(sort): |
25 | 64 | return sort.suffix, sort.expr | 67 | return sort.suffix, sort.expr |
26 | 65 | self.assertEqual(map(sort_data, sort_one), map(sort_data, sort_two)) | 68 | self.assertEqual(map(sort_data, sort_one), map(sort_data, sort_two)) |
27 | @@ -352,7 +355,7 @@ | |||
28 | 352 | # series on the main site, not the code site. | 355 | # series on the main site, not the code site. |
29 | 353 | branch = self.factory.makeProductBranch() | 356 | branch = self.factory.makeProductBranch() |
30 | 354 | series = self.factory.makeProductSeries(product=branch.product) | 357 | series = self.factory.makeProductSeries(product=branch.product) |
32 | 355 | series.branch = branch | 358 | remove_security_proxy_and_shout_at_engineer(series).branch = branch |
33 | 356 | browser = self.getUserBrowser( | 359 | browser = self.getUserBrowser( |
34 | 357 | canonical_url(branch.product, rootsite='code')) | 360 | canonical_url(branch.product, rootsite='code')) |
35 | 358 | link = browser.getLink(re.compile('^' + series.name + '$')) | 361 | link = browser.getLink(re.compile('^' + series.name + '$')) |
36 | @@ -402,4 +405,3 @@ | |||
37 | 402 | 405 | ||
38 | 403 | def test_suite(): | 406 | def test_suite(): |
39 | 404 | return unittest.TestLoader().loadTestsFromName(__name__) | 407 | return unittest.TestLoader().loadTestsFromName(__name__) |
40 | 405 | |||
41 | 406 | 408 | ||
42 | === modified file 'lib/lp/code/browser/tests/test_sourcepackagerecipe.py' | |||
43 | --- lib/lp/code/browser/tests/test_sourcepackagerecipe.py 2010-07-21 21:16:54 +0000 | |||
44 | +++ lib/lp/code/browser/tests/test_sourcepackagerecipe.py 2010-07-22 13:01:10 +0000 | |||
45 | @@ -29,6 +29,7 @@ | |||
46 | 29 | from lp.registry.interfaces.pocket import PackagePublishingPocket | 29 | from lp.registry.interfaces.pocket import PackagePublishingPocket |
47 | 30 | from lp.soyuz.model.processor import ProcessorFamily | 30 | from lp.soyuz.model.processor import ProcessorFamily |
48 | 31 | from lp.testing import ANONYMOUS, BrowserTestCase, login, logout | 31 | from lp.testing import ANONYMOUS, BrowserTestCase, login, logout |
49 | 32 | from lp.testing.factory import remove_security_proxy_and_shout_at_engineer | ||
50 | 32 | 33 | ||
51 | 33 | 34 | ||
52 | 34 | class TestCaseForRecipe(BrowserTestCase): | 35 | class TestCaseForRecipe(BrowserTestCase): |
53 | @@ -45,7 +46,9 @@ | |||
54 | 45 | self.squirrel = self.factory.makeDistroSeries( | 46 | self.squirrel = self.factory.makeDistroSeries( |
55 | 46 | displayname='Secret Squirrel', name='secret', version='100.04', | 47 | displayname='Secret Squirrel', name='secret', version='100.04', |
56 | 47 | distribution=self.ppa.distribution) | 48 | distribution=self.ppa.distribution) |
58 | 48 | self.squirrel.nominatedarchindep = self.squirrel.newArch( | 49 | naked_squirrel = remove_security_proxy_and_shout_at_engineer( |
59 | 50 | self.squirrel) | ||
60 | 51 | naked_squirrel.nominatedarchindep = self.squirrel.newArch( | ||
61 | 49 | 'i386', ProcessorFamily.get(1), False, self.chef, | 52 | 'i386', ProcessorFamily.get(1), False, self.chef, |
62 | 50 | supports_virtualized=True) | 53 | supports_virtualized=True) |
63 | 51 | 54 | ||
64 | @@ -494,7 +497,7 @@ | |||
65 | 494 | def makeBuildJob(self, recipe): | 497 | def makeBuildJob(self, recipe): |
66 | 495 | """Return a build associated with a buildjob.""" | 498 | """Return a build associated with a buildjob.""" |
67 | 496 | build = self.factory.makeSourcePackageRecipeBuild( | 499 | build = self.factory.makeSourcePackageRecipeBuild( |
69 | 497 | recipe=recipe, distroseries=self.squirrel, archive=self.ppa ) | 500 | recipe=recipe, distroseries=self.squirrel, archive=self.ppa) |
70 | 498 | self.factory.makeSourcePackageRecipeBuildJob(recipe_build=build) | 501 | self.factory.makeSourcePackageRecipeBuildJob(recipe_build=build) |
71 | 499 | return build | 502 | return build |
72 | 500 | 503 | ||
73 | @@ -527,6 +530,7 @@ | |||
74 | 527 | self.assertEqual( | 530 | self.assertEqual( |
75 | 528 | set([build1, build2, build3, build4, build5, build6]), | 531 | set([build1, build2, build3, build4, build5, build6]), |
76 | 529 | set(view.builds)) | 532 | set(view.builds)) |
77 | 533 | |||
78 | 530 | def set_day(build, day): | 534 | def set_day(build, day): |
79 | 531 | removeSecurityProxy(build).datebuilt = datetime( | 535 | removeSecurityProxy(build).datebuilt = datetime( |
80 | 532 | 2010, 03, day, tzinfo=utc) | 536 | 2010, 03, day, tzinfo=utc) |
81 | @@ -569,7 +573,8 @@ | |||
82 | 569 | woody = self.factory.makeDistroSeries( | 573 | woody = self.factory.makeDistroSeries( |
83 | 570 | name='woody', displayname='Woody', | 574 | name='woody', displayname='Woody', |
84 | 571 | distribution=self.ppa.distribution) | 575 | distribution=self.ppa.distribution) |
86 | 572 | woody.nominatedarchindep = woody.newArch( | 576 | naked_woody = remove_security_proxy_and_shout_at_engineer(woody) |
87 | 577 | naked_woody.nominatedarchindep = woody.newArch( | ||
88 | 573 | 'i386', ProcessorFamily.get(1), False, self.factory.makePerson(), | 578 | 'i386', ProcessorFamily.get(1), False, self.factory.makePerson(), |
89 | 574 | supports_virtualized=True) | 579 | supports_virtualized=True) |
90 | 575 | 580 | ||
91 | @@ -603,7 +608,8 @@ | |||
92 | 603 | woody = self.factory.makeDistroSeries( | 608 | woody = self.factory.makeDistroSeries( |
93 | 604 | name='woody', displayname='Woody', | 609 | name='woody', displayname='Woody', |
94 | 605 | distribution=self.ppa.distribution) | 610 | distribution=self.ppa.distribution) |
96 | 606 | woody.nominatedarchindep = woody.newArch( | 611 | naked_woody = remove_security_proxy_and_shout_at_engineer(woody) |
97 | 612 | naked_woody.nominatedarchindep = woody.newArch( | ||
98 | 607 | 'i386', ProcessorFamily.get(1), False, self.factory.makePerson(), | 613 | 'i386', ProcessorFamily.get(1), False, self.factory.makePerson(), |
99 | 608 | supports_virtualized=True) | 614 | supports_virtualized=True) |
100 | 609 | 615 | ||
101 | @@ -624,7 +630,8 @@ | |||
102 | 624 | woody = self.factory.makeDistroSeries( | 630 | woody = self.factory.makeDistroSeries( |
103 | 625 | name='woody', displayname='Woody', | 631 | name='woody', displayname='Woody', |
104 | 626 | distribution=self.ppa.distribution) | 632 | distribution=self.ppa.distribution) |
106 | 627 | woody.nominatedarchindep = woody.newArch( | 633 | naked_woody = remove_security_proxy_and_shout_at_engineer(woody) |
107 | 634 | naked_woody.nominatedarchindep = woody.newArch( | ||
108 | 628 | 'i386', ProcessorFamily.get(1), False, self.factory.makePerson(), | 635 | 'i386', ProcessorFamily.get(1), False, self.factory.makePerson(), |
109 | 629 | supports_virtualized=True) | 636 | supports_virtualized=True) |
110 | 630 | 637 | ||
111 | 631 | 638 | ||
112 | === modified file 'lib/lp/code/browser/tests/test_sourcepackagerecipebuild.py' | |||
113 | --- lib/lp/code/browser/tests/test_sourcepackagerecipebuild.py 2010-07-19 09:22:06 +0000 | |||
114 | +++ lib/lp/code/browser/tests/test_sourcepackagerecipebuild.py 2010-07-22 13:01:10 +0000 | |||
115 | @@ -18,6 +18,7 @@ | |||
116 | 18 | from lp.buildmaster.interfaces.buildbase import BuildStatus | 18 | from lp.buildmaster.interfaces.buildbase import BuildStatus |
117 | 19 | from lp.soyuz.model.processor import ProcessorFamily | 19 | from lp.soyuz.model.processor import ProcessorFamily |
118 | 20 | from lp.testing import ANONYMOUS, BrowserTestCase, login, logout | 20 | from lp.testing import ANONYMOUS, BrowserTestCase, login, logout |
119 | 21 | from lp.testing.factory import remove_security_proxy_and_shout_at_engineer | ||
120 | 21 | 22 | ||
121 | 22 | 23 | ||
122 | 23 | class TestSourcePackageRecipeBuild(BrowserTestCase): | 24 | class TestSourcePackageRecipeBuild(BrowserTestCase): |
123 | @@ -36,7 +37,9 @@ | |||
124 | 36 | self.squirrel = self.factory.makeDistroSeries( | 37 | self.squirrel = self.factory.makeDistroSeries( |
125 | 37 | displayname='Secret Squirrel', name='secret', version='100.04', | 38 | displayname='Secret Squirrel', name='secret', version='100.04', |
126 | 38 | distribution=self.ppa.distribution) | 39 | distribution=self.ppa.distribution) |
128 | 39 | self.squirrel.nominatedarchindep = self.squirrel.newArch( | 40 | naked_squirrel = remove_security_proxy_and_shout_at_engineer( |
129 | 41 | self.squirrel) | ||
130 | 42 | naked_squirrel.nominatedarchindep = self.squirrel.newArch( | ||
131 | 40 | 'i386', ProcessorFamily.get(1), False, self.chef, | 43 | 'i386', ProcessorFamily.get(1), False, self.chef, |
132 | 41 | supports_virtualized=True) | 44 | supports_virtualized=True) |
133 | 42 | 45 | ||
134 | 43 | 46 | ||
135 | === modified file 'lib/lp/code/model/tests/test_branch.py' | |||
136 | --- lib/lp/code/model/tests/test_branch.py 2010-07-17 23:15:30 +0000 | |||
137 | +++ lib/lp/code/model/tests/test_branch.py 2010-07-22 13:01:10 +0000 | |||
138 | @@ -537,7 +537,7 @@ | |||
139 | 537 | jobs = list(getUtility(IBranchUpgradeJobSource).iterReady()) | 537 | jobs = list(getUtility(IBranchUpgradeJobSource).iterReady()) |
140 | 538 | self.assertEqual( | 538 | self.assertEqual( |
141 | 539 | jobs, | 539 | jobs, |
143 | 540 | [job,]) | 540 | [job, ]) |
144 | 541 | 541 | ||
145 | 542 | def test_requestUpgrade_no_upgrade_needed(self): | 542 | def test_requestUpgrade_no_upgrade_needed(self): |
146 | 543 | # If a branch doesn't need to be upgraded, requestUpgrade raises an | 543 | # If a branch doesn't need to be upgraded, requestUpgrade raises an |
147 | @@ -635,6 +635,7 @@ | |||
148 | 635 | branch = self.factory.makeProductBranch( | 635 | branch = self.factory.makeProductBranch( |
149 | 636 | product=fooix, owner=eric, name='trunk') | 636 | product=fooix, owner=eric, name='trunk') |
150 | 637 | linked_branch = ICanHasLinkedBranch(future) | 637 | linked_branch = ICanHasLinkedBranch(future) |
151 | 638 | login_person(fooix.owner) | ||
152 | 638 | linked_branch.setBranch(branch) | 639 | linked_branch.setBranch(branch) |
153 | 639 | self.assertEqual( | 640 | self.assertEqual( |
154 | 640 | [linked_branch], | 641 | [linked_branch], |
155 | @@ -827,6 +828,7 @@ | |||
156 | 827 | product = branch.product | 828 | product = branch.product |
157 | 828 | series = self.factory.makeProductSeries(product=product) | 829 | series = self.factory.makeProductSeries(product=product) |
158 | 829 | linked_branch = ICanHasLinkedBranch(series) | 830 | linked_branch = ICanHasLinkedBranch(series) |
159 | 831 | login_person(series.owner) | ||
160 | 830 | linked_branch.setBranch(branch) | 832 | linked_branch.setBranch(branch) |
161 | 831 | self.assertBzrIdentity(branch, linked_branch.bzr_path) | 833 | self.assertBzrIdentity(branch, linked_branch.bzr_path) |
162 | 832 | 834 | ||
163 | @@ -852,6 +854,7 @@ | |||
164 | 852 | removeSecurityProxy(branch.product)) | 854 | removeSecurityProxy(branch.product)) |
165 | 853 | series_link = ICanHasLinkedBranch(series) | 855 | series_link = ICanHasLinkedBranch(series) |
166 | 854 | product_link.setBranch(branch) | 856 | product_link.setBranch(branch) |
167 | 857 | login_person(series.owner) | ||
168 | 855 | series_link.setBranch(branch) | 858 | series_link.setBranch(branch) |
169 | 856 | self.assertBzrIdentity(branch, product_link.bzr_path) | 859 | self.assertBzrIdentity(branch, product_link.bzr_path) |
170 | 857 | 860 | ||
171 | 858 | 861 | ||
172 | === modified file 'lib/lp/code/model/tests/test_linkedbranch.py' | |||
173 | --- lib/lp/code/model/tests/test_linkedbranch.py 2010-04-16 15:06:55 +0000 | |||
174 | +++ lib/lp/code/model/tests/test_linkedbranch.py 2010-07-22 13:01:10 +0000 | |||
175 | @@ -18,6 +18,7 @@ | |||
176 | 18 | from lp.registry.interfaces.distroseries import NoSuchDistroSeries | 18 | from lp.registry.interfaces.distroseries import NoSuchDistroSeries |
177 | 19 | from lp.registry.interfaces.pocket import PackagePublishingPocket | 19 | from lp.registry.interfaces.pocket import PackagePublishingPocket |
178 | 20 | from lp.testing import run_with_login, TestCaseWithFactory | 20 | from lp.testing import run_with_login, TestCaseWithFactory |
179 | 21 | from lp.testing.factory import remove_security_proxy_and_shout_at_engineer | ||
180 | 21 | 22 | ||
181 | 22 | 23 | ||
182 | 23 | class TestProductSeriesLinkedBranch(TestCaseWithFactory): | 24 | class TestProductSeriesLinkedBranch(TestCaseWithFactory): |
183 | @@ -27,7 +28,9 @@ | |||
184 | 27 | def test_branch(self): | 28 | def test_branch(self): |
185 | 28 | # The linked branch of a product series is its branch attribute. | 29 | # The linked branch of a product series is its branch attribute. |
186 | 29 | product_series = self.factory.makeProductSeries() | 30 | product_series = self.factory.makeProductSeries() |
188 | 30 | product_series.branch = self.factory.makeProductBranch( | 31 | naked_product_series = remove_security_proxy_and_shout_at_engineer( |
189 | 32 | product_series) | ||
190 | 33 | naked_product_series.branch = self.factory.makeProductBranch( | ||
191 | 31 | product=product_series.product) | 34 | product=product_series.product) |
192 | 32 | self.assertEqual( | 35 | self.assertEqual( |
193 | 33 | product_series.branch, ICanHasLinkedBranch(product_series).branch) | 36 | product_series.branch, ICanHasLinkedBranch(product_series).branch) |
194 | @@ -35,9 +38,11 @@ | |||
195 | 35 | def test_setBranch(self): | 38 | def test_setBranch(self): |
196 | 36 | # setBranch sets the linked branch of the product series. | 39 | # setBranch sets the linked branch of the product series. |
197 | 37 | product_series = self.factory.makeProductSeries() | 40 | product_series = self.factory.makeProductSeries() |
198 | 41 | naked_product_series = remove_security_proxy_and_shout_at_engineer( | ||
199 | 42 | product_series) | ||
200 | 38 | branch = self.factory.makeProductBranch( | 43 | branch = self.factory.makeProductBranch( |
201 | 39 | product=product_series.product) | 44 | product=product_series.product) |
203 | 40 | ICanHasLinkedBranch(product_series).setBranch(branch) | 45 | ICanHasLinkedBranch(naked_product_series).setBranch(branch) |
204 | 41 | self.assertEqual(branch, product_series.branch) | 46 | self.assertEqual(branch, product_series.branch) |
205 | 42 | 47 | ||
206 | 43 | def test_bzr_path(self): | 48 | def test_bzr_path(self): |
207 | 44 | 49 | ||
208 | === modified file 'lib/lp/code/model/tests/test_sourcepackagerecipebuild.py' | |||
209 | --- lib/lp/code/model/tests/test_sourcepackagerecipebuild.py 2010-07-20 12:12:46 +0000 | |||
210 | +++ lib/lp/code/model/tests/test_sourcepackagerecipebuild.py 2010-07-22 13:01:10 +0000 | |||
211 | @@ -37,6 +37,7 @@ | |||
212 | 37 | from lp.soyuz.model.processor import ProcessorFamily | 37 | from lp.soyuz.model.processor import ProcessorFamily |
213 | 38 | from lp.soyuz.tests.soyuzbuilddhelpers import WaitingSlave | 38 | from lp.soyuz.tests.soyuzbuilddhelpers import WaitingSlave |
214 | 39 | from lp.testing import ANONYMOUS, login, person_logged_in, TestCaseWithFactory | 39 | from lp.testing import ANONYMOUS, login, person_logged_in, TestCaseWithFactory |
215 | 40 | from lp.testing.factory import remove_security_proxy_and_shout_at_engineer | ||
216 | 40 | from lp.testing.fakemethod import FakeMethod | 41 | from lp.testing.fakemethod import FakeMethod |
217 | 41 | from lp.testing.mail_helpers import pop_notifications | 42 | from lp.testing.mail_helpers import pop_notifications |
218 | 42 | 43 | ||
219 | @@ -53,7 +54,9 @@ | |||
220 | 53 | distroseries_i386 = distroseries.newArch( | 54 | distroseries_i386 = distroseries.newArch( |
221 | 54 | 'i386', ProcessorFamily.get(1), False, person, | 55 | 'i386', ProcessorFamily.get(1), False, person, |
222 | 55 | supports_virtualized=True) | 56 | supports_virtualized=True) |
224 | 56 | distroseries.nominatedarchindep = distroseries_i386 | 57 | naked_distroseries = remove_security_proxy_and_shout_at_engineer( |
225 | 58 | distroseries) | ||
226 | 59 | naked_distroseries.nominatedarchindep = distroseries_i386 | ||
227 | 57 | 60 | ||
228 | 58 | return getUtility(ISourcePackageRecipeBuildSource).new( | 61 | return getUtility(ISourcePackageRecipeBuildSource).new( |
229 | 59 | distroseries=distroseries, | 62 | distroseries=distroseries, |
230 | @@ -320,7 +323,7 @@ | |||
231 | 320 | removeSecurityProxy(build).buildstate = BuildStatus.FULLYBUILT | 323 | removeSecurityProxy(build).buildstate = BuildStatus.FULLYBUILT |
232 | 321 | IStore(build).flush() | 324 | IStore(build).flush() |
233 | 322 | build.notify() | 325 | build.notify() |
235 | 323 | (message,) = pop_notifications() | 326 | (message, ) = pop_notifications() |
236 | 324 | requester = build.requester | 327 | requester = build.requester |
237 | 325 | requester_address = format_address( | 328 | requester_address = format_address( |
238 | 326 | requester.displayname, requester.preferredemail.email) | 329 | requester.displayname, requester.preferredemail.email) |
239 | 327 | 330 | ||
240 | === modified file 'lib/lp/registry/browser/tests/distroseries-views.txt' | |||
241 | --- lib/lp/registry/browser/tests/distroseries-views.txt 2010-05-24 22:04:19 +0000 | |||
242 | +++ lib/lp/registry/browser/tests/distroseries-views.txt 2010-07-22 13:01:10 +0000 | |||
243 | @@ -196,7 +196,7 @@ | |||
244 | 196 | >>> [field.__name__ for field in view.form_fields] | 196 | >>> [field.__name__ for field in view.form_fields] |
245 | 197 | ['displayname', 'title', 'summary', 'description', 'status'] | 197 | ['displayname', 'title', 'summary', 'description', 'status'] |
246 | 198 | 198 | ||
248 | 199 | >>> print view.widgets.get('status')._getFormValue() | 199 | >>> print view.widgets.get('status')._getFormValue().title |
249 | 200 | Active Development | 200 | Active Development |
250 | 201 | 201 | ||
251 | 202 | 202 | ||
252 | 203 | 203 | ||
253 | === modified file 'lib/lp/registry/browser/tests/milestone-views.txt' | |||
254 | --- lib/lp/registry/browser/tests/milestone-views.txt 2010-06-30 19:37:09 +0000 | |||
255 | +++ lib/lp/registry/browser/tests/milestone-views.txt 2010-07-22 13:01:10 +0000 | |||
256 | @@ -579,9 +579,13 @@ | |||
257 | 579 | The driver of a series that belongs to an `IDerivativeDistribution` is a | 579 | The driver of a series that belongs to an `IDerivativeDistribution` is a |
258 | 580 | release manager and can create milestones. | 580 | release manager and can create milestones. |
259 | 581 | 581 | ||
260 | 582 | >>> from lp.testing.factory import ( | ||
261 | 583 | ... remove_security_proxy_and_shout_at_engineer) | ||
262 | 582 | >>> distroseries = factory.makeDistroRelease(name='pumpkin') | 584 | >>> distroseries = factory.makeDistroRelease(name='pumpkin') |
263 | 583 | >>> driver = factory.makePerson(name='a-driver') | 585 | >>> driver = factory.makePerson(name='a-driver') |
265 | 584 | >>> distroseries.driver = driver | 586 | >>> naked_distroseries = remove_security_proxy_and_shout_at_engineer( |
266 | 587 | ... distroseries) | ||
267 | 588 | >>> naked_distroseries.driver = driver | ||
268 | 585 | >>> login_person(driver) | 589 | >>> login_person(driver) |
269 | 586 | 590 | ||
270 | 587 | >>> form = { | 591 | >>> form = { |
271 | 588 | 592 | ||
272 | === modified file 'lib/lp/registry/browser/tests/productseries-views.txt' | |||
273 | --- lib/lp/registry/browser/tests/productseries-views.txt 2010-06-13 02:01:25 +0000 | |||
274 | +++ lib/lp/registry/browser/tests/productseries-views.txt 2010-07-22 13:01:10 +0000 | |||
275 | @@ -255,6 +255,8 @@ | |||
276 | 255 | 255 | ||
277 | 256 | >>> from datetime import datetime | 256 | >>> from datetime import datetime |
278 | 257 | >>> from pytz import UTC | 257 | >>> from pytz import UTC |
279 | 258 | >>> from lp.testing.factory import ( | ||
280 | 259 | ... remove_security_proxy_and_shout_at_engineer) | ||
281 | 258 | 260 | ||
282 | 259 | >>> product = factory.makeProduct(name="field", displayname='Field') | 261 | >>> product = factory.makeProduct(name="field", displayname='Field') |
283 | 260 | >>> productseries = factory.makeProductSeries( | 262 | >>> productseries = factory.makeProductSeries( |
284 | @@ -263,7 +265,9 @@ | |||
285 | 263 | 265 | ||
286 | 264 | # Hack the creation date for testing purposes. | 266 | # Hack the creation date for testing purposes. |
287 | 265 | >>> test_date = datetime(2009, 05, 01, 19, 34, 24, tzinfo=UTC) | 267 | >>> test_date = datetime(2009, 05, 01, 19, 34, 24, tzinfo=UTC) |
289 | 266 | >>> productseries.datecreated = test_date | 268 | >>> naked_productseries = remove_security_proxy_and_shout_at_engineer( |
290 | 269 | ... productseries) | ||
291 | 270 | >>> naked_productseries.datecreated = test_date | ||
292 | 267 | 271 | ||
293 | 268 | Users without edit permission cannot access the view. | 272 | Users without edit permission cannot access the view. |
294 | 269 | 273 | ||
295 | @@ -470,7 +474,7 @@ | |||
296 | 470 | 474 | ||
297 | 471 | The series status is set to obsolete and the releasefileglob was set to None. | 475 | The series status is set to obsolete and the releasefileglob was set to None. |
298 | 472 | 476 | ||
300 | 473 | >>> print productseries.status | 477 | >>> print productseries.status.title |
301 | 474 | Obsolete | 478 | Obsolete |
302 | 475 | >>> print productseries.releasefileglob | 479 | >>> print productseries.releasefileglob |
303 | 476 | None | 480 | None |
304 | 477 | 481 | ||
305 | === modified file 'lib/lp/registry/stories/webservice/xx-project-registry.txt' | |||
306 | --- lib/lp/registry/stories/webservice/xx-project-registry.txt 2010-06-14 18:32:58 +0000 | |||
307 | +++ lib/lp/registry/stories/webservice/xx-project-registry.txt 2010-07-22 13:01:10 +0000 | |||
308 | @@ -847,15 +847,17 @@ | |||
309 | 847 | The entry for a project series is available at its canonical URL on the | 847 | The entry for a project series is available at its canonical URL on the |
310 | 848 | virtual host. | 848 | virtual host. |
311 | 849 | 849 | ||
312 | 850 | >>> from zope.security.proxy import removeSecurityProxy | ||
313 | 850 | >>> login('test@canonical.com') | 851 | >>> login('test@canonical.com') |
314 | 851 | >>> babadoo_owner = factory.makePerson(name='babadoo-owner') | 852 | >>> babadoo_owner = factory.makePerson(name='babadoo-owner') |
315 | 852 | >>> babadoo = factory.makeProduct(name='babadoo', owner=babadoo_owner) | 853 | >>> babadoo = factory.makeProduct(name='babadoo', owner=babadoo_owner) |
316 | 853 | >>> foobadoo = factory.makeProductSeries( | 854 | >>> foobadoo = factory.makeProductSeries( |
317 | 854 | ... product=babadoo, name='foobadoo', owner=babadoo_owner) | 855 | ... product=babadoo, name='foobadoo', owner=babadoo_owner) |
319 | 855 | >>> foobadoo.summary = u'Foobadoo support for Babadoo' | 856 | >>> removeSecurityProxy(foobadoo).summary = ( |
320 | 857 | ... u'Foobadoo support for Babadoo') | ||
321 | 856 | >>> fooey = factory.makeAnyBranch( | 858 | >>> fooey = factory.makeAnyBranch( |
322 | 857 | ... product=babadoo, name='fooey', owner=babadoo_owner) | 859 | ... product=babadoo, name='fooey', owner=babadoo_owner) |
324 | 858 | >>> foobadoo.branch = fooey | 860 | >>> removeSecurityProxy(foobadoo).branch = fooey |
325 | 859 | >>> logout() | 861 | >>> logout() |
326 | 860 | 862 | ||
327 | 861 | >>> babadoo_foobadoo = webservice.get('/babadoo/foobadoo').jsonBody() | 863 | >>> babadoo_foobadoo = webservice.get('/babadoo/foobadoo').jsonBody() |
328 | 862 | 864 | ||
329 | === modified file 'lib/lp/registry/tests/test_distroseries.py' | |||
330 | --- lib/lp/registry/tests/test_distroseries.py 2010-06-23 23:23:28 +0000 | |||
331 | +++ lib/lp/registry/tests/test_distroseries.py 2010-07-22 13:01:10 +0000 | |||
332 | @@ -24,6 +24,7 @@ | |||
333 | 24 | active_publishing_status, PackagePublishingStatus) | 24 | active_publishing_status, PackagePublishingStatus) |
334 | 25 | from lp.soyuz.model.processor import ProcessorFamilySet | 25 | from lp.soyuz.model.processor import ProcessorFamilySet |
335 | 26 | from lp.testing import TestCase, TestCaseWithFactory | 26 | from lp.testing import TestCase, TestCaseWithFactory |
336 | 27 | from lp.testing.factory import remove_security_proxy_and_shout_at_engineer | ||
337 | 27 | from lp.soyuz.tests.test_publishing import SoyuzTestPublisher | 28 | from lp.soyuz.tests.test_publishing import SoyuzTestPublisher |
338 | 28 | from lp.translations.interfaces.translations import ( | 29 | from lp.translations.interfaces.translations import ( |
339 | 29 | TranslationsBranchImportMode) | 30 | TranslationsBranchImportMode) |
340 | @@ -285,7 +286,9 @@ | |||
341 | 285 | self.linkPackage('hot') | 286 | self.linkPackage('hot') |
342 | 286 | self.makeSeriesPackage('cold') | 287 | self.makeSeriesPackage('cold') |
343 | 287 | product_series = self.linkPackage('cold') | 288 | product_series = self.linkPackage('cold') |
345 | 288 | product_series.product.bugtraker = self.factory.makeBugTracker() | 289 | naked_product_series = remove_security_proxy_and_shout_at_engineer( |
346 | 290 | product_series) | ||
347 | 291 | naked_product_series.product.bugtraker = self.factory.makeBugTracker() | ||
348 | 289 | packagings = self.series.getPrioritizedlPackagings() | 292 | packagings = self.series.getPrioritizedlPackagings() |
349 | 290 | names = [packaging.sourcepackagename.name for packaging in packagings] | 293 | names = [packaging.sourcepackagename.name for packaging in packagings] |
350 | 291 | expected = [u'hot', u'cold', u'linked'] | 294 | expected = [u'hot', u'cold', u'linked'] |
351 | @@ -296,7 +299,9 @@ | |||
352 | 296 | self.linkPackage('translatable') | 299 | self.linkPackage('translatable') |
353 | 297 | self.makeSeriesPackage('withbranch') | 300 | self.makeSeriesPackage('withbranch') |
354 | 298 | product_series = self.linkPackage('withbranch') | 301 | product_series = self.linkPackage('withbranch') |
356 | 299 | product_series.branch = self.factory.makeBranch() | 302 | naked_product_series = remove_security_proxy_and_shout_at_engineer( |
357 | 303 | product_series) | ||
358 | 304 | naked_product_series.branch = self.factory.makeBranch() | ||
359 | 300 | packagings = self.series.getPrioritizedlPackagings() | 305 | packagings = self.series.getPrioritizedlPackagings() |
360 | 301 | names = [packaging.sourcepackagename.name for packaging in packagings] | 306 | names = [packaging.sourcepackagename.name for packaging in packagings] |
361 | 302 | expected = [u'translatable', u'linked', u'withbranch'] | 307 | expected = [u'translatable', u'linked', u'withbranch'] |
362 | @@ -308,8 +313,10 @@ | |||
363 | 308 | self.linkPackage('translatable') | 313 | self.linkPackage('translatable') |
364 | 309 | self.makeSeriesPackage('importabletranslatable') | 314 | self.makeSeriesPackage('importabletranslatable') |
365 | 310 | product_series = self.linkPackage('importabletranslatable') | 315 | product_series = self.linkPackage('importabletranslatable') |
368 | 311 | product_series.branch = self.factory.makeBranch() | 316 | naked_product_series = remove_security_proxy_and_shout_at_engineer( |
369 | 312 | product_series.translations_autoimport_mode = ( | 317 | product_series) |
370 | 318 | naked_product_series.branch = self.factory.makeBranch() | ||
371 | 319 | naked_product_series.translations_autoimport_mode = ( | ||
372 | 313 | TranslationsBranchImportMode.IMPORT_TEMPLATES) | 320 | TranslationsBranchImportMode.IMPORT_TEMPLATES) |
373 | 314 | packagings = self.series.getPrioritizedlPackagings() | 321 | packagings = self.series.getPrioritizedlPackagings() |
374 | 315 | names = [packaging.sourcepackagename.name for packaging in packagings] | 322 | names = [packaging.sourcepackagename.name for packaging in packagings] |
375 | @@ -343,7 +350,9 @@ | |||
376 | 343 | 350 | ||
377 | 344 | new_distroseries = ( | 351 | new_distroseries = ( |
378 | 345 | self.factory.makeDistroRelease(name=u"sampleseries")) | 352 | self.factory.makeDistroRelease(name=u"sampleseries")) |
380 | 346 | new_distroseries.hide_all_translations = False | 353 | naked_new_distroseries = remove_security_proxy_and_shout_at_engineer( |
381 | 354 | new_distroseries) | ||
382 | 355 | naked_new_distroseries.hide_all_translations = False | ||
383 | 347 | transaction.commit() | 356 | transaction.commit() |
384 | 348 | translatables = self._get_translatables() | 357 | translatables = self._get_translatables() |
385 | 349 | self.failUnlessEqual( | 358 | self.failUnlessEqual( |
386 | @@ -365,7 +374,7 @@ | |||
387 | 365 | translatables, | 374 | translatables, |
388 | 366 | self._ref_translatables(u"sampleseries"))) | 375 | self._ref_translatables(u"sampleseries"))) |
389 | 367 | 376 | ||
391 | 368 | new_distroseries.hide_all_translations = True | 377 | naked_new_distroseries.hide_all_translations = True |
392 | 369 | transaction.commit() | 378 | transaction.commit() |
393 | 370 | translatables = self._get_translatables() | 379 | translatables = self._get_translatables() |
394 | 371 | self.failUnlessEqual( | 380 | self.failUnlessEqual( |
395 | 372 | 381 | ||
396 | === modified file 'lib/lp/registry/tests/test_sourcepackage.py' | |||
397 | --- lib/lp/registry/tests/test_sourcepackage.py 2010-02-24 03:06:54 +0000 | |||
398 | +++ lib/lp/registry/tests/test_sourcepackage.py 2010-07-22 13:01:10 +0000 | |||
399 | @@ -22,6 +22,7 @@ | |||
400 | 22 | from lp.code.interfaces.seriessourcepackagebranch import ( | 22 | from lp.code.interfaces.seriessourcepackagebranch import ( |
401 | 23 | IMakeOfficialBranchLinks) | 23 | IMakeOfficialBranchLinks) |
402 | 24 | from lp.testing import TestCaseWithFactory | 24 | from lp.testing import TestCaseWithFactory |
403 | 25 | from lp.testing.factory import remove_security_proxy_and_shout_at_engineer | ||
404 | 25 | from lp.testing.views import create_initialized_view | 26 | from lp.testing.views import create_initialized_view |
405 | 26 | from canonical.testing.layers import DatabaseFunctionalLayer | 27 | from canonical.testing.layers import DatabaseFunctionalLayer |
406 | 27 | 28 | ||
407 | @@ -252,11 +253,17 @@ | |||
408 | 252 | 253 | ||
409 | 253 | self.obsolete_productseries = self.factory.makeProductSeries( | 254 | self.obsolete_productseries = self.factory.makeProductSeries( |
410 | 254 | name='obsolete', product=self.product) | 255 | name='obsolete', product=self.product) |
412 | 255 | self.obsolete_productseries.status = SeriesStatus.OBSOLETE | 256 | naked_obsolete_productseries = ( |
413 | 257 | remove_security_proxy_and_shout_at_engineer( | ||
414 | 258 | self.obsolete_productseries)) | ||
415 | 259 | naked_obsolete_productseries.status = SeriesStatus.OBSOLETE | ||
416 | 256 | 260 | ||
417 | 257 | self.dev_productseries = self.factory.makeProductSeries( | 261 | self.dev_productseries = self.factory.makeProductSeries( |
418 | 258 | name='current', product=self.product) | 262 | name='current', product=self.product) |
420 | 259 | self.dev_productseries.status = SeriesStatus.DEVELOPMENT | 263 | naked_dev_productseries = ( |
421 | 264 | remove_security_proxy_and_shout_at_engineer( | ||
422 | 265 | self.dev_productseries)) | ||
423 | 266 | naked_dev_productseries.status = SeriesStatus.DEVELOPMENT | ||
424 | 260 | 267 | ||
425 | 261 | self.distribution = self.factory.makeDistribution( | 268 | self.distribution = self.factory.makeDistribution( |
426 | 262 | name='youbuntu', displayname='Youbuntu', owner=self.owner) | 269 | name='youbuntu', displayname='Youbuntu', owner=self.owner) |
427 | 263 | 270 | ||
428 | === modified file 'lib/lp/soyuz/browser/tests/test_distrosourcepackagerelease.py' | |||
429 | --- lib/lp/soyuz/browser/tests/test_distrosourcepackagerelease.py 2010-07-20 12:06:36 +0000 | |||
430 | +++ lib/lp/soyuz/browser/tests/test_distrosourcepackagerelease.py 2010-07-22 13:01:10 +0000 | |||
431 | @@ -14,6 +14,7 @@ | |||
432 | 14 | DistributionSourcePackageRelease) | 14 | DistributionSourcePackageRelease) |
433 | 15 | from lp.soyuz.tests.test_publishing import SoyuzTestPublisher | 15 | from lp.soyuz.tests.test_publishing import SoyuzTestPublisher |
434 | 16 | from lp.testing import TestCaseWithFactory | 16 | from lp.testing import TestCaseWithFactory |
435 | 17 | from lp.testing.factory import remove_security_proxy_and_shout_at_engineer | ||
436 | 17 | from lp.testing.views import create_initialized_view | 18 | from lp.testing.views import create_initialized_view |
437 | 18 | 19 | ||
438 | 19 | 20 | ||
439 | @@ -27,7 +28,12 @@ | |||
440 | 27 | # The package must be published for the page to render. | 28 | # The package must be published for the page to render. |
441 | 28 | stp = SoyuzTestPublisher() | 29 | stp = SoyuzTestPublisher() |
442 | 29 | distroseries = stp.setUpDefaultDistroSeries() | 30 | distroseries = stp.setUpDefaultDistroSeries() |
444 | 30 | distro = distroseries.distribution | 31 | naked_distroseries = remove_security_proxy_and_shout_at_engineer( |
445 | 32 | distroseries) | ||
446 | 33 | # XXX Abel Deuring, 2010-07-21, bug 608240. This is scary. But | ||
447 | 34 | # if we use distroseries.distribution instead, | ||
448 | 35 | # test_spr_files_deleted() and test_spr_files_one() fail. | ||
449 | 36 | distro = naked_distroseries.distribution | ||
450 | 31 | source_package_release = stp.getPubSource().sourcepackagerelease | 37 | source_package_release = stp.getPubSource().sourcepackagerelease |
451 | 32 | self.dspr = DistributionSourcePackageRelease( | 38 | self.dspr = DistributionSourcePackageRelease( |
452 | 33 | distro, source_package_release) | 39 | distro, source_package_release) |
453 | 34 | 40 | ||
454 | === modified file 'lib/lp/soyuz/browser/tests/test_sourcepackagerelease.py' | |||
455 | --- lib/lp/soyuz/browser/tests/test_sourcepackagerelease.py 2010-07-20 12:06:36 +0000 | |||
456 | +++ lib/lp/soyuz/browser/tests/test_sourcepackagerelease.py 2010-07-22 13:01:10 +0000 | |||
457 | @@ -16,6 +16,7 @@ | |||
458 | 16 | from canonical.testing import ( | 16 | from canonical.testing import ( |
459 | 17 | DatabaseFunctionalLayer, LaunchpadFunctionalLayer) | 17 | DatabaseFunctionalLayer, LaunchpadFunctionalLayer) |
460 | 18 | from lp.testing import TestCaseWithFactory | 18 | from lp.testing import TestCaseWithFactory |
461 | 19 | from lp.testing.factory import remove_security_proxy_and_shout_at_engineer | ||
462 | 19 | from lp.testing.views import create_initialized_view | 20 | from lp.testing.views import create_initialized_view |
463 | 20 | 21 | ||
464 | 21 | 22 | ||
465 | @@ -64,20 +65,23 @@ | |||
466 | 64 | 65 | ||
467 | 65 | def test_highlighted_copyright_is_None(self): | 66 | def test_highlighted_copyright_is_None(self): |
468 | 66 | expected = '' | 67 | expected = '' |
470 | 67 | self.source_package_release.copyright = None | 68 | remove_security_proxy_and_shout_at_engineer( |
471 | 69 | self.source_package_release).copyright = None | ||
472 | 68 | view = create_initialized_view( | 70 | view = create_initialized_view( |
473 | 69 | self.source_package_release, '+copyright') | 71 | self.source_package_release, '+copyright') |
474 | 70 | self.assertEqual(expected, view.highlighted_copyright) | 72 | self.assertEqual(expected, view.highlighted_copyright) |
475 | 71 | 73 | ||
476 | 72 | def test_highlighted_copyright_no_matches(self): | 74 | def test_highlighted_copyright_no_matches(self): |
477 | 73 | expected = 'nothing to see and/or do.' | 75 | expected = 'nothing to see and/or do.' |
479 | 74 | self.source_package_release.copyright = expected | 76 | remove_security_proxy_and_shout_at_engineer( |
480 | 77 | self.source_package_release).copyright = expected | ||
481 | 75 | view = create_initialized_view( | 78 | view = create_initialized_view( |
482 | 76 | self.source_package_release, '+copyright') | 79 | self.source_package_release, '+copyright') |
483 | 77 | self.assertEqual(expected, view.highlighted_copyright) | 80 | self.assertEqual(expected, view.highlighted_copyright) |
484 | 78 | 81 | ||
485 | 79 | def test_highlighted_copyright_match_url(self): | 82 | def test_highlighted_copyright_match_url(self): |
487 | 80 | self.source_package_release.copyright = ( | 83 | remove_security_proxy_and_shout_at_engineer( |
488 | 84 | self.source_package_release).copyright = ( | ||
489 | 81 | 'Downloaded from https://upstream.dom/fnord/no/ and') | 85 | 'Downloaded from https://upstream.dom/fnord/no/ and') |
490 | 82 | expected = ( | 86 | expected = ( |
491 | 83 | 'Downloaded from ' | 87 | 'Downloaded from ' |
492 | @@ -88,7 +92,8 @@ | |||
493 | 88 | self.assertEqual(expected, view.highlighted_copyright) | 92 | self.assertEqual(expected, view.highlighted_copyright) |
494 | 89 | 93 | ||
495 | 90 | def test_highlighted_copyright_match_path(self): | 94 | def test_highlighted_copyright_match_path(self): |
497 | 91 | self.source_package_release.copyright = ( | 95 | remove_security_proxy_and_shout_at_engineer( |
498 | 96 | self.source_package_release).copyright = ( | ||
499 | 92 | 'See /usr/share/common-licenses/GPL') | 97 | 'See /usr/share/common-licenses/GPL') |
500 | 93 | expected = ( | 98 | expected = ( |
501 | 94 | 'See ' | 99 | 'See ' |
502 | @@ -98,7 +103,8 @@ | |||
503 | 98 | self.assertEqual(expected, view.highlighted_copyright) | 103 | self.assertEqual(expected, view.highlighted_copyright) |
504 | 99 | 104 | ||
505 | 100 | def test_highlighted_copyright_match_multiple(self): | 105 | def test_highlighted_copyright_match_multiple(self): |
507 | 101 | self.source_package_release.copyright = ( | 106 | remove_security_proxy_and_shout_at_engineer( |
508 | 107 | self.source_package_release).copyright = ( | ||
509 | 102 | 'See /usr/share/common-licenses/GPL or https://osi.org/mit') | 108 | 'See /usr/share/common-licenses/GPL or https://osi.org/mit') |
510 | 103 | expected = ( | 109 | expected = ( |
511 | 104 | 'See ' | 110 | 'See ' |
512 | 105 | 111 | ||
513 | === modified file 'lib/lp/soyuz/tests/test_publishing.py' | |||
514 | --- lib/lp/soyuz/tests/test_publishing.py 2010-07-21 14:14:54 +0000 | |||
515 | +++ lib/lp/soyuz/tests/test_publishing.py 2010-07-22 13:01:10 +0000 | |||
516 | @@ -44,7 +44,8 @@ | |||
517 | 44 | from lp.soyuz.interfaces.queue import PackageUploadStatus | 44 | from lp.soyuz.interfaces.queue import PackageUploadStatus |
518 | 45 | from canonical.launchpad.scripts import FakeLogger | 45 | from canonical.launchpad.scripts import FakeLogger |
519 | 46 | from lp.testing import TestCaseWithFactory | 46 | from lp.testing import TestCaseWithFactory |
521 | 47 | from lp.testing.factory import LaunchpadObjectFactory | 47 | from lp.testing.factory import ( |
522 | 48 | LaunchpadObjectFactory, remove_security_proxy_and_shout_at_engineer) | ||
523 | 48 | from lp.testing.fakemethod import FakeMethod | 49 | from lp.testing.fakemethod import FakeMethod |
524 | 49 | 50 | ||
525 | 50 | 51 | ||
526 | @@ -146,7 +147,10 @@ | |||
527 | 146 | PackageUploadStatus.DONE: 'setDone', | 147 | PackageUploadStatus.DONE: 'setDone', |
528 | 147 | PackageUploadStatus.ACCEPTED: 'setAccepted', | 148 | PackageUploadStatus.ACCEPTED: 'setAccepted', |
529 | 148 | } | 149 | } |
531 | 149 | method = getattr(package_upload, status_to_method[upload_status]) | 150 | naked_package_upload = remove_security_proxy_and_shout_at_engineer( |
532 | 151 | package_upload) | ||
533 | 152 | method = getattr( | ||
534 | 153 | naked_package_upload, status_to_method[upload_status]) | ||
535 | 150 | method() | 154 | method() |
536 | 151 | 155 | ||
537 | 152 | return package_upload | 156 | return package_upload |
538 | @@ -222,7 +226,9 @@ | |||
539 | 222 | changes_file_name=changes_file_name, | 226 | changes_file_name=changes_file_name, |
540 | 223 | changes_file_content=changes_file_content, | 227 | changes_file_content=changes_file_content, |
541 | 224 | upload_status=upload_status) | 228 | upload_status=upload_status) |
543 | 225 | package_upload.addSource(spr) | 229 | naked_package_upload = remove_security_proxy_and_shout_at_engineer( |
544 | 230 | package_upload) | ||
545 | 231 | naked_package_upload.addSource(spr) | ||
546 | 226 | 232 | ||
547 | 227 | if filename is None: | 233 | if filename is None: |
548 | 228 | filename = "%s_%s.dsc" % (sourcename, version) | 234 | filename = "%s_%s.dsc" % (sourcename, version) |
549 | 229 | 235 | ||
550 | === modified file 'lib/lp/testing/factory.py' | |||
551 | --- lib/lp/testing/factory.py 2010-07-21 14:41:26 +0000 | |||
552 | +++ lib/lp/testing/factory.py 2010-07-22 13:01:10 +0000 | |||
553 | @@ -13,8 +13,10 @@ | |||
554 | 13 | __metaclass__ = type | 13 | __metaclass__ = type |
555 | 14 | __all__ = [ | 14 | __all__ = [ |
556 | 15 | 'GPGSigningContext', | 15 | 'GPGSigningContext', |
557 | 16 | 'is_security_proxied_or_harmless', | ||
558 | 16 | 'LaunchpadObjectFactory', | 17 | 'LaunchpadObjectFactory', |
559 | 17 | 'ObjectFactory', | 18 | 'ObjectFactory', |
560 | 19 | 'remove_security_proxy_and_shout_at_engineer', | ||
561 | 18 | ] | 20 | ] |
562 | 19 | 21 | ||
563 | 20 | from contextlib import nested | 22 | from contextlib import nested |
564 | @@ -25,18 +27,22 @@ | |||
565 | 25 | from email.mime.text import MIMEText | 27 | from email.mime.text import MIMEText |
566 | 26 | from email.mime.multipart import MIMEMultipart | 28 | from email.mime.multipart import MIMEMultipart |
567 | 27 | from itertools import count | 29 | from itertools import count |
568 | 30 | from operator import isSequenceType | ||
569 | 28 | import os.path | 31 | import os.path |
570 | 29 | from random import randint | 32 | from random import randint |
571 | 30 | from StringIO import StringIO | 33 | from StringIO import StringIO |
572 | 34 | import sys | ||
573 | 31 | from textwrap import dedent | 35 | from textwrap import dedent |
574 | 32 | from threading import local | 36 | from threading import local |
575 | 37 | from types import InstanceType | ||
576 | 33 | 38 | ||
577 | 34 | import pytz | 39 | import pytz |
578 | 35 | 40 | ||
579 | 36 | from twisted.python.util import mergeFunctionMetadata | 41 | from twisted.python.util import mergeFunctionMetadata |
580 | 37 | 42 | ||
581 | 38 | from zope.component import ComponentLookupError, getUtility | 43 | from zope.component import ComponentLookupError, getUtility |
583 | 39 | from zope.security.proxy import removeSecurityProxy | 44 | from zope.security.proxy import ( |
584 | 45 | builtin_isinstance, Proxy, ProxyFactory, removeSecurityProxy) | ||
585 | 40 | 46 | ||
586 | 41 | from canonical.autodecorate import AutoDecorate | 47 | from canonical.autodecorate import AutoDecorate |
587 | 42 | from canonical.config import config | 48 | from canonical.config import config |
588 | @@ -325,7 +331,7 @@ | |||
589 | 325 | branch_id, rcstype, url, cvs_root, cvs_module) | 331 | branch_id, rcstype, url, cvs_root, cvs_module) |
590 | 326 | 332 | ||
591 | 327 | 333 | ||
593 | 328 | class LaunchpadObjectFactory(ObjectFactory): | 334 | class BareLaunchpadObjectFactory(ObjectFactory): |
594 | 329 | """Factory methods for creating Launchpad objects. | 335 | """Factory methods for creating Launchpad objects. |
595 | 330 | 336 | ||
596 | 331 | All the factory methods should be callable with no parameters. | 337 | All the factory methods should be callable with no parameters. |
597 | @@ -744,8 +750,8 @@ | |||
598 | 744 | # We don't want to login() as the person used to create the product, | 750 | # We don't want to login() as the person used to create the product, |
599 | 745 | # so we remove the security proxy before creating the series. | 751 | # so we remove the security proxy before creating the series. |
600 | 746 | naked_product = removeSecurityProxy(product) | 752 | naked_product = removeSecurityProxy(product) |
603 | 747 | return naked_product.newSeries(owner=owner, name=name, | 753 | return ProxyFactory( |
604 | 748 | summary=summary) | 754 | naked_product.newSeries(owner=owner, name=name, summary=summary)) |
605 | 749 | 755 | ||
606 | 750 | def makeProject(self, name=None, displayname=None, title=None, | 756 | def makeProject(self, name=None, displayname=None, title=None, |
607 | 751 | homepageurl=None, summary=None, owner=None, | 757 | homepageurl=None, summary=None, owner=None, |
608 | @@ -1671,7 +1677,7 @@ | |||
609 | 1671 | description=self.getUniqueString(), | 1677 | description=self.getUniqueString(), |
610 | 1672 | parent_series=parent_series, owner=distribution.owner) | 1678 | parent_series=parent_series, owner=distribution.owner) |
611 | 1673 | series.status = status | 1679 | series.status = status |
613 | 1674 | return series | 1680 | return ProxyFactory(series) |
614 | 1675 | 1681 | ||
615 | 1676 | # Most people think of distro releases as distro series. | 1682 | # Most people think of distro releases as distro series. |
616 | 1677 | makeDistroSeries = makeDistroRelease | 1683 | makeDistroSeries = makeDistroRelease |
617 | @@ -1780,7 +1786,7 @@ | |||
618 | 1780 | 1786 | ||
619 | 1781 | def makeRecipeText(self, *branches): | 1787 | def makeRecipeText(self, *branches): |
620 | 1782 | if len(branches) == 0: | 1788 | if len(branches) == 0: |
622 | 1783 | branches = (self.makeAnyBranch(),) | 1789 | branches = (self.makeAnyBranch(), ) |
623 | 1784 | base_branch = branches[0] | 1790 | base_branch = branches[0] |
624 | 1785 | other_branches = branches[1:] | 1791 | other_branches = branches[1:] |
625 | 1786 | text = MINIMAL_RECIPE_TEXT % base_branch.bzr_identity | 1792 | text = MINIMAL_RECIPE_TEXT % base_branch.bzr_identity |
626 | @@ -1943,7 +1949,7 @@ | |||
627 | 1943 | productseries = self.makeProductSeries(owner=owner) | 1949 | productseries = self.makeProductSeries(owner=owner) |
628 | 1944 | # Make it use Translations, otherwise there's little point | 1950 | # Make it use Translations, otherwise there's little point |
629 | 1945 | # to us creating a template for it. | 1951 | # to us creating a template for it. |
631 | 1946 | productseries.product.official_rosetta = True | 1952 | removeSecurityProxy(productseries).product.official_rosetta = True |
632 | 1947 | templateset = getUtility(IPOTemplateSet) | 1953 | templateset = getUtility(IPOTemplateSet) |
633 | 1948 | subset = templateset.getSubset( | 1954 | subset = templateset.getSubset( |
634 | 1949 | distroseries, sourcepackagename, productseries) | 1955 | distroseries, sourcepackagename, productseries) |
635 | @@ -2718,3 +2724,72 @@ | |||
636 | 2718 | new_uuid = getUtility(ITemporaryStorageManager).new(blob, expires) | 2724 | new_uuid = getUtility(ITemporaryStorageManager).new(blob, expires) |
637 | 2719 | 2725 | ||
638 | 2720 | return getUtility(ITemporaryStorageManager).fetch(new_uuid) | 2726 | return getUtility(ITemporaryStorageManager).fetch(new_uuid) |
639 | 2727 | |||
640 | 2728 | |||
641 | 2729 | # Some factory methods return simple Python types. We don't add | ||
642 | 2730 | # security wrappers for them. | ||
643 | 2731 | unwrapped_types = ( | ||
644 | 2732 | DSCFile, InstanceType, Message, datetime, int, str, unicode) | ||
645 | 2733 | |||
646 | 2734 | def is_security_proxied_or_harmless(obj): | ||
647 | 2735 | """Check that the given object is security wrapped or a harmless object.""" | ||
648 | 2736 | if obj is None: | ||
649 | 2737 | return True | ||
650 | 2738 | if builtin_isinstance(obj, Proxy): | ||
651 | 2739 | return True | ||
652 | 2740 | if type(obj) in unwrapped_types: | ||
653 | 2741 | return True | ||
654 | 2742 | if isSequenceType(obj): | ||
655 | 2743 | for element in obj: | ||
656 | 2744 | if not is_security_proxied_or_harmless(element): | ||
657 | 2745 | return False | ||
658 | 2746 | return True | ||
659 | 2747 | return False | ||
660 | 2748 | |||
661 | 2749 | |||
662 | 2750 | class LaunchpadObjectFactory: | ||
663 | 2751 | """A wrapper around `BareLaunchpadObjectFactory`. | ||
664 | 2752 | |||
665 | 2753 | Ensure that each object created by a `BareLaunchpadObjectFactory` method | ||
666 | 2754 | is either of a simple Python type or is security proxied. | ||
667 | 2755 | |||
668 | 2756 | A warning message is printed to stderr if a factory method creates | ||
669 | 2757 | an object without a security proxy. | ||
670 | 2758 | |||
671 | 2759 | Whereever you see such a warning: fix it! | ||
672 | 2760 | """ | ||
673 | 2761 | def __init__(self): | ||
674 | 2762 | self._factory = BareLaunchpadObjectFactory() | ||
675 | 2763 | |||
676 | 2764 | def __getattr__(self, name): | ||
677 | 2765 | attr = getattr(self._factory, name) | ||
678 | 2766 | if callable(attr): | ||
679 | 2767 | |||
680 | 2768 | def guarded_method(*args, **kw): | ||
681 | 2769 | result = attr(*args, **kw) | ||
682 | 2770 | if not is_security_proxied_or_harmless(result): | ||
683 | 2771 | message = ( | ||
684 | 2772 | "PLEASE FIX: LaunchpadObjectFactory.%s returns an " | ||
685 | 2773 | "unproxied object." % name) | ||
686 | 2774 | print >>sys.stderr, message | ||
687 | 2775 | return result | ||
688 | 2776 | return guarded_method | ||
689 | 2777 | else: | ||
690 | 2778 | return attr | ||
691 | 2779 | |||
692 | 2780 | |||
693 | 2781 | def remove_security_proxy_and_shout_at_engineer(obj): | ||
694 | 2782 | """Remove an object's security proxy and print a warning. | ||
695 | 2783 | |||
696 | 2784 | A number of LaunchpadObjectFactory methods returned objects without | ||
697 | 2785 | a security proxy. This is now no longer possible, but a number of | ||
698 | 2786 | tests rely on unrestricted access to object attributes. | ||
699 | 2787 | |||
700 | 2788 | This function should only be used in legacy tests which fail because | ||
701 | 2789 | they expect unproxied objects. | ||
702 | 2790 | """ | ||
703 | 2791 | print >>sys.stderr, ( | ||
704 | 2792 | "\nWarning: called removeSecurityProxy() for %r without a check if " | ||
705 | 2793 | "this reasonable. Look for a call of " | ||
706 | 2794 | "remove_security_proxy_and_shout_at_engineer(some_object)." % obj) | ||
707 | 2795 | return removeSecurityProxy(obj) | ||
708 | 2721 | 2796 | ||
709 | === modified file 'lib/lp/testing/tests/test_factory.py' | |||
710 | --- lib/lp/testing/tests/test_factory.py 2010-07-17 18:40:02 +0000 | |||
711 | +++ lib/lp/testing/tests/test_factory.py 2010-07-22 13:01:10 +0000 | |||
712 | @@ -8,11 +8,13 @@ | |||
713 | 8 | import unittest | 8 | import unittest |
714 | 9 | 9 | ||
715 | 10 | from zope.component import getUtility | 10 | from zope.component import getUtility |
716 | 11 | from zope.security.proxy import removeSecurityProxy | ||
717 | 11 | 12 | ||
718 | 12 | from canonical.launchpad.webapp.interfaces import ILaunchBag | 13 | from canonical.launchpad.webapp.interfaces import ILaunchBag |
719 | 13 | from canonical.testing.layers import DatabaseFunctionalLayer | 14 | from canonical.testing.layers import DatabaseFunctionalLayer |
720 | 14 | from lp.code.enums import CodeImportReviewStatus | 15 | from lp.code.enums import CodeImportReviewStatus |
721 | 15 | from lp.testing import TestCaseWithFactory | 16 | from lp.testing import TestCaseWithFactory |
722 | 17 | from lp.testing.factory import is_security_proxied_or_harmless | ||
723 | 16 | 18 | ||
724 | 17 | 19 | ||
725 | 18 | class TestFactory(TestCaseWithFactory): | 20 | class TestFactory(TestCaseWithFactory): |
726 | @@ -39,6 +41,54 @@ | |||
727 | 39 | self.assertIsNot(None, person) | 41 | self.assertIsNot(None, person) |
728 | 40 | self.assertEqual(person, current_person) | 42 | self.assertEqual(person, current_person) |
729 | 41 | 43 | ||
730 | 44 | def test_is_security_proxied_or_harmless__none(self): | ||
731 | 45 | # is_security_proxied_or_harmless() considers the None object | ||
732 | 46 | # to be a harmless object. | ||
733 | 47 | self.assertTrue(is_security_proxied_or_harmless(None)) | ||
734 | 48 | |||
735 | 49 | def test_is_security_proxied_or_harmless__int(self): | ||
736 | 50 | # is_security_proxied_or_harmless() considers integers | ||
737 | 51 | # to be harmless. | ||
738 | 52 | self.assertTrue(is_security_proxied_or_harmless(1)) | ||
739 | 53 | |||
740 | 54 | def test_is_security_proxied_or_harmless__string(self): | ||
741 | 55 | # is_security_proxied_or_harmless() considers strings | ||
742 | 56 | # to be harmless. | ||
743 | 57 | self.assertTrue(is_security_proxied_or_harmless('abc')) | ||
744 | 58 | |||
745 | 59 | def test_is_security_proxied_or_harmless__unicode(self): | ||
746 | 60 | # is_security_proxied_or_harmless() considers unicode objects | ||
747 | 61 | # to be harmless. | ||
748 | 62 | self.assertTrue(is_security_proxied_or_harmless(u'abc')) | ||
749 | 63 | |||
750 | 64 | def test_is_security_proxied_or_harmless__proxied_object(self): | ||
751 | 65 | # is_security_proxied_or_harmless() treats security proxied | ||
752 | 66 | # objects as harmless. | ||
753 | 67 | proxied_person = self.factory.makePerson() | ||
754 | 68 | self.assertTrue(is_security_proxied_or_harmless(proxied_person)) | ||
755 | 69 | |||
756 | 70 | def test_is_security_proxied_or_harmless__unproxied_object(self): | ||
757 | 71 | # is_security_proxied_or_harmless() treats security proxied | ||
758 | 72 | # objects as harmless. | ||
759 | 73 | unproxied_person = removeSecurityProxy(self.factory.makePerson()) | ||
760 | 74 | self.assertFalse(is_security_proxied_or_harmless(unproxied_person)) | ||
761 | 75 | |||
762 | 76 | def test_is_security_proxied_or_harmless__sequence_harmless_content(self): | ||
763 | 77 | # is_security_proxied_or_harmless() checks all elements | ||
764 | 78 | # of a sequence. If all elements are harmless, so is the | ||
765 | 79 | # sequence. | ||
766 | 80 | proxied_person = self.factory.makePerson() | ||
767 | 81 | self.assertTrue( | ||
768 | 82 | is_security_proxied_or_harmless([1, '2', proxied_person])) | ||
769 | 83 | |||
770 | 84 | def test_is_security_proxied_or_harmless__sequence_harmful_content(self): | ||
771 | 85 | # is_security_proxied_or_harmless() checks all elements | ||
772 | 86 | # of a sequence. If at least elements are harmful, so is the | ||
773 | 87 | # sequence. | ||
774 | 88 | unproxied_person = removeSecurityProxy(self.factory.makePerson()) | ||
775 | 89 | self.assertFalse( | ||
776 | 90 | is_security_proxied_or_harmless([1, '2', unproxied_person])) | ||
777 | 91 | |||
778 | 42 | 92 | ||
779 | 43 | def test_suite(): | 93 | def test_suite(): |
780 | 44 | return unittest.TestLoader().loadTestsFromName(__name__) | 94 | return unittest.TestLoader().loadTestsFromName(__name__) |
781 | 45 | 95 | ||
782 | === modified file 'lib/lp/translations/browser/tests/test_breadcrumbs.py' | |||
783 | --- lib/lp/translations/browser/tests/test_breadcrumbs.py 2010-07-19 15:31:57 +0000 | |||
784 | +++ lib/lp/translations/browser/tests/test_breadcrumbs.py 2010-07-22 13:01:10 +0000 | |||
785 | @@ -9,6 +9,7 @@ | |||
786 | 9 | 9 | ||
787 | 10 | from lp.services.worlddata.interfaces.language import ILanguageSet | 10 | from lp.services.worlddata.interfaces.language import ILanguageSet |
788 | 11 | from lp.testing.breadcrumbs import BaseBreadcrumbTestCase | 11 | from lp.testing.breadcrumbs import BaseBreadcrumbTestCase |
789 | 12 | from lp.testing.factory import remove_security_proxy_and_shout_at_engineer | ||
790 | 12 | from lp.translations.interfaces.distroserieslanguage import ( | 13 | from lp.translations.interfaces.distroserieslanguage import ( |
791 | 13 | IDistroSeriesLanguageSet) | 14 | IDistroSeriesLanguageSet) |
792 | 14 | from lp.translations.interfaces.productserieslanguage import ( | 15 | from lp.translations.interfaces.productserieslanguage import ( |
793 | @@ -109,7 +110,8 @@ | |||
794 | 109 | name='crumb-tester', displayname="Crumb Tester") | 110 | name='crumb-tester', displayname="Crumb Tester") |
795 | 110 | series = self.factory.makeDistroRelease( | 111 | series = self.factory.makeDistroRelease( |
796 | 111 | name="test", version="1.0", distribution=distribution) | 112 | name="test", version="1.0", distribution=distribution) |
798 | 112 | series.hide_all_translations = False | 113 | naked_series = remove_security_proxy_and_shout_at_engineer(series) |
799 | 114 | naked_series.hide_all_translations = False | ||
800 | 113 | serieslanguage = getUtility(IDistroSeriesLanguageSet).getDummy( | 115 | serieslanguage = getUtility(IDistroSeriesLanguageSet).getDummy( |
801 | 114 | series, self.language) | 116 | series, self.language) |
802 | 115 | 117 | ||
803 | 116 | 118 | ||
804 | === modified file 'lib/lp/translations/doc/translations-export-to-branch.txt' | |||
805 | --- lib/lp/translations/doc/translations-export-to-branch.txt 2010-06-16 07:22:57 +0000 | |||
806 | +++ lib/lp/translations/doc/translations-export-to-branch.txt 2010-07-22 13:01:10 +0000 | |||
807 | @@ -220,8 +220,12 @@ | |||
808 | 220 | >>> from email import message_from_string | 220 | >>> from email import message_from_string |
809 | 221 | >>> from lp.services.mail import stub | 221 | >>> from lp.services.mail import stub |
810 | 222 | >>> from lp.codehosting.vfs import get_rw_server | 222 | >>> from lp.codehosting.vfs import get_rw_server |
811 | 223 | >>> from lp.testing.factory import ( | ||
812 | 224 | ... remove_security_proxy_and_shout_at_engineer) | ||
813 | 223 | >>> productseries = factory.makeProductSeries() | 225 | >>> productseries = factory.makeProductSeries() |
815 | 224 | >>> productseries.translations_branch = factory.makeBranch() | 226 | >>> naked_productseries = remove_security_proxy_and_shout_at_engineer( |
816 | 227 | ... productseries) | ||
817 | 228 | >>> naked_productseries.translations_branch = factory.makeBranch() | ||
818 | 225 | >>> template = factory.makePOTemplate(productseries=productseries) | 229 | >>> template = factory.makePOTemplate(productseries=productseries) |
819 | 226 | >>> potmsgset = factory.makePOTMsgSet(template) | 230 | >>> potmsgset = factory.makePOTMsgSet(template) |
820 | 227 | >>> pofile = removeSecurityProxy( | 231 | >>> pofile = removeSecurityProxy( |
821 | 228 | 232 | ||
822 | === modified file 'lib/lp/translations/stories/buildfarm/xx-build-summary.txt' | |||
823 | --- lib/lp/translations/stories/buildfarm/xx-build-summary.txt 2010-03-16 11:09:46 +0000 | |||
824 | +++ lib/lp/translations/stories/buildfarm/xx-build-summary.txt 2010-07-22 13:01:10 +0000 | |||
825 | @@ -14,6 +14,8 @@ | |||
826 | 14 | ... ILibraryFileAliasSet) | 14 | ... ILibraryFileAliasSet) |
827 | 15 | >>> from canonical.launchpad.scripts.logger import QuietFakeLogger | 15 | >>> from canonical.launchpad.scripts.logger import QuietFakeLogger |
828 | 16 | >>> from lp.buildmaster.interfaces.buildqueue import IBuildQueueSet | 16 | >>> from lp.buildmaster.interfaces.buildqueue import IBuildQueueSet |
829 | 17 | >>> from lp.testing.factory import ( | ||
830 | 18 | ... remove_security_proxy_and_shout_at_engineer) | ||
831 | 17 | >>> from lp.testing.fakemethod import FakeMethod | 19 | >>> from lp.testing.fakemethod import FakeMethod |
832 | 18 | >>> from lp.translations.interfaces.translations import ( | 20 | >>> from lp.translations.interfaces.translations import ( |
833 | 19 | ... TranslationsBranchImportMode) | 21 | ... TranslationsBranchImportMode) |
834 | @@ -29,12 +31,15 @@ | |||
835 | 29 | 31 | ||
836 | 30 | >>> productseries = factory.makeProductSeries(owner=owner) | 32 | >>> productseries = factory.makeProductSeries(owner=owner) |
837 | 31 | >>> product = productseries.product | 33 | >>> product = productseries.product |
839 | 32 | >>> product.official_rosetta = True | 34 | >>> naked_product = remove_security_proxy_and_shout_at_engineer(product) |
840 | 35 | >>> naked_product.official_rosetta = True | ||
841 | 33 | >>> branch = factory.makeProductBranch(product=product, owner=owner) | 36 | >>> branch = factory.makeProductBranch(product=product, owner=owner) |
842 | 34 | >>> branch_url = branch.unique_name | 37 | >>> branch_url = branch.unique_name |
843 | 35 | 38 | ||
846 | 36 | >>> productseries.branch = factory.makeBranch() | 39 | >>> naked_productseries = remove_security_proxy_and_shout_at_engineer( |
847 | 37 | >>> productseries.translations_autoimport_mode = ( | 40 | ... productseries) |
848 | 41 | >>> naked_productseries.branch = factory.makeBranch() | ||
849 | 42 | >>> naked_productseries.translations_autoimport_mode = ( | ||
850 | 38 | ... TranslationsBranchImportMode.IMPORT_TEMPLATES) | 43 | ... TranslationsBranchImportMode.IMPORT_TEMPLATES) |
851 | 39 | >>> specific_job = factory.makeTranslationTemplatesBuildJob(branch=branch) | 44 | >>> specific_job = factory.makeTranslationTemplatesBuildJob(branch=branch) |
852 | 40 | >>> buildqueue = getUtility(IBuildQueueSet).getByJob(specific_job.job) | 45 | >>> buildqueue = getUtility(IBuildQueueSet).getByJob(specific_job.job) |
Thanks for doing this. We discussed this over IRL chat and came up with many little improvements: chiefly renaming _LaunchpadObjec tFactory to BareLaunchpadOb jectFactory, moving some code out of a nested function, fixing some corner cases, and adding a test for the proxy-checking function since it turned out to be a lot less trivial than originally thought.
This is often the case when engineers say a change will be trivial.
Jeroen