Merge lp:~bac/launchpad/bug-753965 into lp:launchpad
- bug-753965
- Merge into devel
Status: | Merged |
---|---|
Approved by: | Brad Crittenden |
Approved revision: | no longer in the source branch. |
Merged at revision: | 12812 |
Proposed branch: | lp:~bac/launchpad/bug-753965 |
Merge into: | lp:launchpad |
Diff against target: |
1027 lines (+486/-155) 10 files modified
lib/lp/bugs/browser/structuralsubscription.py (+27/-13) lib/lp/bugs/model/structuralsubscription.py (+1/-0) lib/lp/registry/browser/tests/test_subscription_links.py (+367/-71) lib/lp/registry/templates/distribution-index.pt (+13/-10) lib/lp/registry/templates/distributionsourcepackage-index.pt (+13/-10) lib/lp/registry/templates/distroseries-index.pt (+13/-10) lib/lp/registry/templates/milestone-index.pt (+13/-10) lib/lp/registry/templates/product-index.pt (+13/-11) lib/lp/registry/templates/productseries-index.pt (+13/-10) lib/lp/registry/templates/project-index.pt (+13/-10) |
To merge this branch: | bzr merge lp:~bac/launchpad/bug-753965 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Benji York (community) | code | Approve | |
Review via email: mp+57262@code.launchpad.net |
Commit message
[r=benji][bug=753965] Do not show structural subscription links if the IStructuralSubs
Description of the change
= Summary =
If the IStructuralSubs
then the structural subscription links should not be shown.
== Proposed fix ==
Check the service usage before enabling the link. Also don't call
structural-
used.
== Pre-implementation notes ==
None.
== Implementation details ==
As above.
== Tests ==
bin/test -vvt test_subscripti
== Demo and Q/A ==
Create a new project in launchpad.dev. Note that the subscription links
are present. Go to 'Configure bug tracker' and mark it as external.
Note the links no longer appear.
= Launchpad lint =
Lint will be fixed.
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/
443: Line exceeds 78 characters.
./lib/lp/
641: E302 expected 2 blank lines, found 1
642: E301 expected 1 blank line, found 0
649: E301 expected 1 blank line, found 0
681: E301 expected 1 blank line, found 0
747: E301 expected 1 blank line, found 0
801: E301 expected 1 blank line, found 0
Benji York (benji) wrote : | # |
We discussed the accidentally-
the diff in IRC.
I would add failure messages to the asserts inside your custom assert
methods: assertOldLinkMi
assertNewLinksM
Skipping DistroView.setUp on line 345 of the diff and calling
BrowserTestCase
to DistroView.setUp the tests still pass.
Also, you didn't start it, but the manual test suite construction in
test_suite is kinda ugly and brittle (a test could easily be dropped
from the list and not noticed). Here's a change that uses the standard
unittest test loader but ignores test cases from the base class that we
want to avoid (also available at http://
=== modified file 'lib/lp/
--- lib/lp/
+++ lib/lp/
@@ -855,40 +855,19 @@
+class CustomTestLoade
+ """A test loader that avoids running tests from a base class."""
+
+ def getTestCaseName
+ # If we're asked about which tests to run for _TestStructSubs, reply
+ # with an empty list.
+ if testCaseClass is _TestStructSubs:
+ return []
+ else:
+ return super(CustomTes
+ testCaseClass)
+
+
def test_suite():
"""Return the `IStructuralSub
-
- # Manually construct the test suite to avoid having tests from the base
- # class _TestStructSubs run.
- suite = unittest.
- suite.addTest(
- suite.addTest(
- suite.addTest(
- suite.addTest(
- suite.addTest(
- suite.addTest(
- suite.addTest(
- suite.addTest(
- suite.addTest(
- suite.addTest(
- suite.addTest(
- suite.addTest(
- suite.addTest(
-
- suite.addTest(
- suite.addTest(
- suite.addTest(
- suite.addTest(
- suite.addTest(
- suite.addTest(
- suite.addTest(
- DistributionSou
- suite.addTest(
- DistributionSou
- suite.addTest(
Brad Crittenden (bac) wrote : | # |
Thanks for the review and suggestions Benji.
As mentioned earlier, the test loader is a vast improvement.
The ProductMileston
Preview Diff
1 | === modified file 'lib/lp/bugs/browser/structuralsubscription.py' |
2 | --- lib/lp/bugs/browser/structuralsubscription.py 2011-04-06 15:58:38 +0000 |
3 | +++ lib/lp/bugs/browser/structuralsubscription.py 2011-04-13 01:26:33 +0000 |
4 | @@ -49,6 +49,7 @@ |
5 | custom_widget, |
6 | LaunchpadFormView, |
7 | ) |
8 | +from lp.app.enums import ServiceUsage |
9 | from lp.app.widgets.itemswidgets import LabeledMultiCheckBoxWidget |
10 | from lp.bugs.interfaces.bugtask import ( |
11 | BugTaskImportance, |
12 | @@ -354,35 +355,47 @@ |
13 | """ |
14 | sst = self._getSST() |
15 | |
16 | - # ProjectGroup milestones aren't really structural subscription |
17 | - # targets as they're not real milestones, so you can't subscribe to |
18 | - # them. |
19 | - enabled = not IProjectGroupMilestone.providedBy(sst) |
20 | if sst.userHasBugSubscriptions(self.user): |
21 | text = 'Edit bug mail subscription' |
22 | icon = 'edit' |
23 | else: |
24 | text = 'Subscribe to bug mail' |
25 | icon = 'add' |
26 | - if not enabled or ( |
27 | - not sst.userCanAlterBugSubscription(self.user, self.user)): |
28 | + # ProjectGroup milestones aren't really structural subscription |
29 | + # targets as they're not real milestones, so you can't subscribe to |
30 | + # them. |
31 | + if (not IProjectGroupMilestone.providedBy(sst) and |
32 | + sst.userCanAlterBugSubscription(self.user, self.user)): |
33 | + enabled = True |
34 | + else: |
35 | enabled = False |
36 | + |
37 | return Link('+subscribe', text, icon=icon, enabled=enabled) |
38 | |
39 | + @property |
40 | + def _enabled(self): |
41 | + """Should the link be enabled? |
42 | + |
43 | + True if the target uses Launchpad for bugs and the user can alter the |
44 | + bug subscriptions. |
45 | + """ |
46 | + sst = self._getSST() |
47 | + target = sst |
48 | + if sst.parent_subscription_target is not None: |
49 | + target = sst.parent_subscription_target |
50 | + return (target.bug_tracking_usage == ServiceUsage.LAUNCHPAD and |
51 | + sst.userCanAlterBugSubscription(self.user, self.user)) |
52 | + |
53 | @enabled_with_permission('launchpad.AnyPerson') |
54 | def subscribe_to_bug_mail(self): |
55 | - sst = self._getSST() |
56 | - enabled = sst.userCanAlterBugSubscription(self.user, self.user) |
57 | text = 'Subscribe to bug mail' |
58 | - return Link('#', text, icon='add', hidden=True, enabled=enabled) |
59 | + return Link('#', text, icon='add', hidden=True, enabled=self._enabled) |
60 | |
61 | @enabled_with_permission('launchpad.AnyPerson') |
62 | def edit_bug_mail(self): |
63 | - sst = self._getSST() |
64 | - enabled = sst.userCanAlterBugSubscription(self.user, self.user) |
65 | text = 'Edit bug mail' |
66 | return Link('+subscriptions', text, icon='edit', site='bugs', |
67 | - enabled=enabled) |
68 | + enabled=self._enabled) |
69 | |
70 | |
71 | def expose_structural_subscription_data_to_js(context, request, |
72 | @@ -430,7 +443,8 @@ |
73 | IJSONRequestCache(request).objects['administratedTeams'] = info |
74 | |
75 | |
76 | -def expose_user_subscriptions_to_js(user, subscriptions, request, target=None): |
77 | +def expose_user_subscriptions_to_js(user, subscriptions, request, |
78 | + target=None): |
79 | """Make the user's subscriptions available to JavaScript.""" |
80 | info = {} |
81 | api_request = IWebServiceClientRequest(request) |
82 | |
83 | === modified file 'lib/lp/bugs/model/structuralsubscription.py' |
84 | --- lib/lp/bugs/model/structuralsubscription.py 2011-03-29 05:38:15 +0000 |
85 | +++ lib/lp/bugs/model/structuralsubscription.py 2011-04-13 01:26:33 +0000 |
86 | @@ -355,6 +355,7 @@ |
87 | |
88 | # Nobody else can, unless the context is a IDistributionSourcePackage, |
89 | # in which case the drivers or owner can. |
90 | + |
91 | if IDistributionSourcePackage.providedBy(self): |
92 | for driver in self.distribution.drivers: |
93 | if subscribed_by.inTeam(driver): |
94 | |
95 | === modified file 'lib/lp/registry/browser/tests/test_subscription_links.py' |
96 | --- lib/lp/registry/browser/tests/test_subscription_links.py 2011-04-04 20:15:16 +0000 |
97 | +++ lib/lp/registry/browser/tests/test_subscription_links.py 2011-04-13 01:26:33 +0000 |
98 | @@ -52,18 +52,30 @@ |
99 | self.contents, 'menu-link-edit_bug_mail') |
100 | |
101 | def assertOldLinkMissing(self): |
102 | - self.assertEqual(None, self.old_link) |
103 | + self.assertEqual( |
104 | + None, self.old_link, |
105 | + "Found unexpected link: %s" % self.old_link) |
106 | |
107 | def assertOldLinkPresent(self): |
108 | - self.assertNotEqual(None, self.old_link) |
109 | + self.assertNotEqual( |
110 | + None, self.old_link, |
111 | + "Expected +subscribe link missing") |
112 | |
113 | def assertNewLinksMissing(self): |
114 | - self.assertEqual(None, self.new_subscribe_link) |
115 | - self.assertEqual(None, self.new_edit_link) |
116 | + self.assertEqual( |
117 | + None, self.new_subscribe_link, |
118 | + "Found unexpected link: %s" % self.new_subscribe_link) |
119 | + self.assertEqual( |
120 | + None, self.new_edit_link, |
121 | + "Found unexpected link: %s" % self.new_edit_link) |
122 | |
123 | def assertNewLinksPresent(self): |
124 | - self.assertNotEqual(None, self.new_subscribe_link) |
125 | - self.assertNotEqual(None, self.new_edit_link) |
126 | + self.assertNotEqual( |
127 | + None, self.new_subscribe_link, |
128 | + "Expected subscribe_to_bug_mail link missing") |
129 | + self.assertNotEqual( |
130 | + None, self.new_edit_link, |
131 | + "Expected edit_bug_mail link missing") |
132 | |
133 | |
134 | class _TestStructSubs(TestCaseWithFactory, _TestResultsMixin): |
135 | @@ -110,7 +122,7 @@ |
136 | |
137 | def test_subscribe_link_feature_flag_off_user(self): |
138 | self._create_scenario(self.regular_user, None) |
139 | - self.assertNotEqual(None, self.old_link) |
140 | + self.assertOldLinkPresent() |
141 | self.assertNewLinksMissing() |
142 | |
143 | def test_subscribe_link_feature_flag_on_user(self): |
144 | @@ -122,7 +134,7 @@ |
145 | self._create_scenario(ANONYMOUS, None) |
146 | # The old subscribe link is actually shown to anonymous users but the |
147 | # behavior has changed with the new link. |
148 | - self.assertNotEqual(None, self.old_link) |
149 | + self.assertOldLinkPresent() |
150 | self.assertNewLinksMissing() |
151 | |
152 | def test_subscribe_link_feature_flag_on_anonymous(self): |
153 | @@ -132,75 +144,76 @@ |
154 | self.assertNewLinksMissing() |
155 | |
156 | |
157 | -class TestProductViewStructSubs(_TestStructSubs): |
158 | +class ProductView(_TestStructSubs): |
159 | """Test structural subscriptions on the product view.""" |
160 | |
161 | rootsite = None |
162 | view = '+index' |
163 | |
164 | def setUp(self): |
165 | - super(TestProductViewStructSubs, self).setUp() |
166 | + super(ProductView, self).setUp() |
167 | self.target = self.factory.makeProduct(official_malone=True) |
168 | |
169 | |
170 | -class TestProductBugsStructSubs(TestProductViewStructSubs): |
171 | +class ProductBugs(ProductView): |
172 | """Test structural subscriptions on the product bugs view.""" |
173 | |
174 | rootsite = 'bugs' |
175 | view = '+bugs-index' |
176 | |
177 | |
178 | -class TestProjectGroupViewStructSubs(_TestStructSubs): |
179 | +class ProjectGroupView(_TestStructSubs): |
180 | """Test structural subscriptions on the project group view.""" |
181 | |
182 | rootsite = None |
183 | view = '+index' |
184 | |
185 | def setUp(self): |
186 | - super(TestProjectGroupViewStructSubs, self).setUp() |
187 | + super(ProjectGroupView, self).setUp() |
188 | self.target = self.factory.makeProject() |
189 | self.factory.makeProduct( |
190 | project=self.target, official_malone=True) |
191 | |
192 | |
193 | -class TestProjectGroupBugsStructSubs(TestProjectGroupViewStructSubs): |
194 | +class ProjectGroupBugs(ProjectGroupView): |
195 | """Test structural subscriptions on the project group bugs view.""" |
196 | |
197 | rootsite = 'bugs' |
198 | view = '+bugs' |
199 | |
200 | |
201 | -class TestProductSeriesViewStructSubs(_TestStructSubs): |
202 | +class ProductSeriesView(_TestStructSubs): |
203 | """Test structural subscriptions on the product series view.""" |
204 | |
205 | rootsite = None |
206 | view = '+index' |
207 | |
208 | def setUp(self): |
209 | - super(TestProductSeriesViewStructSubs, self).setUp() |
210 | - self.target = self.factory.makeProductSeries() |
211 | - |
212 | - |
213 | -class TestProductSeriesBugsStructSubs(TestProductSeriesViewStructSubs): |
214 | + super(ProductSeriesView, self).setUp() |
215 | + product = self.factory.makeProduct(official_malone=True) |
216 | + self.target = self.factory.makeProductSeries(product=product) |
217 | + |
218 | + |
219 | +class ProductSeriesBugs(ProductSeriesView): |
220 | """Test structural subscriptions on the product series bugs view.""" |
221 | |
222 | rootsite = 'bugs' |
223 | view = '+bugs-index' |
224 | |
225 | def setUp(self): |
226 | - super(TestProductSeriesBugsStructSubs, self).setUp() |
227 | + super(ProductSeriesBugs, self).setUp() |
228 | with person_logged_in(self.target.product.owner): |
229 | self.target.product.official_malone = True |
230 | |
231 | |
232 | -class TestDistributionSourcePackageViewStructSubs(_TestStructSubs): |
233 | +class DistributionSourcePackageView(_TestStructSubs): |
234 | """Test structural subscriptions on the distro src pkg view.""" |
235 | |
236 | rootsite = None |
237 | view = '+index' |
238 | |
239 | def setUp(self): |
240 | - super(TestDistributionSourcePackageViewStructSubs, self).setUp() |
241 | + super(DistributionSourcePackageView, self).setUp() |
242 | distro = self.factory.makeDistribution() |
243 | with person_logged_in(distro.owner): |
244 | distro.official_malone = True |
245 | @@ -213,15 +226,14 @@ |
246 | test_subscribe_link_feature_flag_on_owner = None |
247 | |
248 | |
249 | -class TestDistributionSourcePackageBugsStructSubs( |
250 | - TestDistributionSourcePackageViewStructSubs): |
251 | +class DistributionSourcePackageBugs(DistributionSourcePackageView): |
252 | """Test structural subscriptions on the distro src pkg bugs view.""" |
253 | |
254 | rootsite = 'bugs' |
255 | view = '+bugs' |
256 | |
257 | |
258 | -class TestDistroViewStructSubs(BrowserTestCase, _TestResultsMixin): |
259 | +class DistroView(BrowserTestCase, _TestResultsMixin): |
260 | """Test structural subscriptions on the distribution view. |
261 | |
262 | Distributions are special. They are IStructuralSubscriptionTargets but |
263 | @@ -238,7 +250,7 @@ |
264 | view = '+index' |
265 | |
266 | def setUp(self): |
267 | - super(TestDistroViewStructSubs, self).setUp() |
268 | + super(DistroView, self).setUp() |
269 | self.target = self.factory.makeDistribution() |
270 | with person_logged_in(self.target.owner): |
271 | self.target.official_malone = True |
272 | @@ -329,14 +341,13 @@ |
273 | self.assertNewLinksMissing() |
274 | |
275 | def test_subscribe_link_feature_flag_on_admin(self): |
276 | - from lp.testing.sampledata import ADMIN_EMAIL |
277 | admin = getUtility(IPersonSet).getByEmail(ADMIN_EMAIL) |
278 | self._create_scenario(admin, 'on') |
279 | self.assertOldLinkMissing() |
280 | self.assertNewLinksPresent() |
281 | |
282 | |
283 | -class TestDistroBugsStructSubs(TestDistroViewStructSubs): |
284 | +class DistroBugs(DistroView): |
285 | """Test structural subscriptions on the distro bugs view.""" |
286 | |
287 | rootsite = 'bugs' |
288 | @@ -344,7 +355,7 @@ |
289 | |
290 | def test_subscribe_link_feature_flag_off_owner(self): |
291 | self._create_scenario(self.target.owner, None) |
292 | - self.assertNotEqual(None, self.old_link) |
293 | + self.assertOldLinkPresent() |
294 | self.assertNewLinksMissing() |
295 | |
296 | def test_subscribe_link_feature_flag_on_owner(self): |
297 | @@ -354,7 +365,7 @@ |
298 | |
299 | def test_subscribe_link_feature_flag_off_user(self): |
300 | self._create_scenario(self.regular_user, None) |
301 | - self.assertNotEqual(None, self.old_link) |
302 | + self.assertOldLinkPresent() |
303 | self.assertNewLinksMissing() |
304 | |
305 | def test_subscribe_link_feature_flag_on_user_no_bug_super(self): |
306 | @@ -374,7 +385,7 @@ |
307 | |
308 | def test_subscribe_link_feature_flag_off_anonymous(self): |
309 | self._create_scenario(ANONYMOUS, None) |
310 | - self.assertNotEqual(None, self.old_link) |
311 | + self.assertOldLinkPresent() |
312 | self.assertNewLinksMissing() |
313 | |
314 | def test_subscribe_link_feature_flag_on_anonymous(self): |
315 | @@ -388,7 +399,7 @@ |
316 | self.target.setBugSupervisor( |
317 | self.regular_user, admin) |
318 | self._create_scenario(self.regular_user, None) |
319 | - self.assertNotEqual(None, self.old_link) |
320 | + self.assertOldLinkPresent() |
321 | self.assertNewLinksMissing() |
322 | |
323 | def test_subscribe_link_feature_flag_on_bug_super(self): |
324 | @@ -403,7 +414,7 @@ |
325 | def test_subscribe_link_feature_flag_off_admin(self): |
326 | admin = getUtility(IPersonSet).getByEmail(ADMIN_EMAIL) |
327 | self._create_scenario(admin, None) |
328 | - self.assertNotEqual(None, self.old_link) |
329 | + self.assertOldLinkPresent() |
330 | self.assertNewLinksMissing() |
331 | |
332 | def test_subscribe_link_feature_flag_on_admin(self): |
333 | @@ -414,17 +425,17 @@ |
334 | self.assertNewLinksPresent() |
335 | |
336 | |
337 | -class TestDistroMilestoneViewStructSubs(TestDistroViewStructSubs): |
338 | +class DistroMilestoneView(DistroView): |
339 | """Test structural subscriptions on the distro milestones.""" |
340 | |
341 | def setUp(self): |
342 | - super(TestDistroMilestoneViewStructSubs, self).setUp() |
343 | + super(DistroMilestoneView, self).setUp() |
344 | self.distro = self.target |
345 | self.target = self.factory.makeMilestone(distribution=self.distro) |
346 | |
347 | def test_subscribe_link_feature_flag_off_owner(self): |
348 | self._create_scenario(self.distro.owner, None) |
349 | - self.assertNotEqual(None, self.old_link) |
350 | + self.assertOldLinkPresent() |
351 | self.assertNewLinksMissing() |
352 | |
353 | def test_subscribe_link_feature_flag_on_owner(self): |
354 | @@ -434,7 +445,7 @@ |
355 | |
356 | def test_subscribe_link_feature_flag_off_user(self): |
357 | self._create_scenario(self.regular_user, None) |
358 | - self.assertNotEqual(None, self.old_link) |
359 | + self.assertOldLinkPresent() |
360 | self.assertNewLinksMissing() |
361 | |
362 | def test_subscribe_link_feature_flag_on_user_no_bug_super(self): |
363 | @@ -454,7 +465,7 @@ |
364 | |
365 | def test_subscribe_link_feature_flag_off_anonymous(self): |
366 | self._create_scenario(ANONYMOUS, None) |
367 | - self.assertNotEqual(None, self.old_link) |
368 | + self.assertOldLinkPresent() |
369 | self.assertNewLinksMissing() |
370 | |
371 | def test_subscribe_link_feature_flag_on_anonymous(self): |
372 | @@ -468,7 +479,7 @@ |
373 | self.distro.setBugSupervisor( |
374 | self.regular_user, admin) |
375 | self._create_scenario(self.regular_user, None) |
376 | - self.assertNotEqual(None, self.old_link) |
377 | + self.assertOldLinkPresent() |
378 | self.assertNewLinksMissing() |
379 | |
380 | def test_subscribe_link_feature_flag_on_bug_super(self): |
381 | @@ -483,7 +494,7 @@ |
382 | def test_subscribe_link_feature_flag_off_admin(self): |
383 | admin = getUtility(IPersonSet).getByEmail(ADMIN_EMAIL) |
384 | self._create_scenario(admin, None) |
385 | - self.assertNotEqual(None, self.old_link) |
386 | + self.assertOldLinkPresent() |
387 | self.assertNewLinksMissing() |
388 | |
389 | def test_subscribe_link_feature_flag_on_admin(self): |
390 | @@ -494,11 +505,11 @@ |
391 | self.assertNewLinksPresent() |
392 | |
393 | |
394 | -class TestProductMilestoneViewStructSubs(TestDistroViewStructSubs): |
395 | +class ProductMilestoneView(DistroView): |
396 | """Test structural subscriptions on the product milestones.""" |
397 | |
398 | def setUp(self): |
399 | - super(TestProductMilestoneViewStructSubs, self).setUp() |
400 | + super(ProductMilestoneView, self).setUp() |
401 | self.product = self.factory.makeProduct() |
402 | with person_logged_in(self.product.owner): |
403 | self.product.official_malone = True |
404 | @@ -507,7 +518,7 @@ |
405 | |
406 | def test_subscribe_link_feature_flag_off_owner(self): |
407 | self._create_scenario(self.product.owner, None) |
408 | - self.assertNotEqual(None, self.old_link) |
409 | + self.assertOldLinkPresent() |
410 | self.assertNewLinksMissing() |
411 | |
412 | def test_subscribe_link_feature_flag_on_owner(self): |
413 | @@ -517,7 +528,7 @@ |
414 | |
415 | def test_subscribe_link_feature_flag_off_user(self): |
416 | self._create_scenario(self.regular_user, None) |
417 | - self.assertNotEqual(None, self.old_link) |
418 | + self.assertOldLinkPresent() |
419 | self.assertNewLinksMissing() |
420 | |
421 | # There are no special bug supervisor rules for products. |
422 | @@ -528,7 +539,7 @@ |
423 | |
424 | def test_subscribe_link_feature_flag_off_anonymous(self): |
425 | self._create_scenario(ANONYMOUS, None) |
426 | - self.assertNotEqual(None, self.old_link) |
427 | + self.assertOldLinkPresent() |
428 | self.assertNewLinksMissing() |
429 | |
430 | def test_subscribe_link_feature_flag_on_anonymous(self): |
431 | @@ -539,7 +550,7 @@ |
432 | def test_subscribe_link_feature_flag_off_admin(self): |
433 | admin = getUtility(IPersonSet).getByEmail(ADMIN_EMAIL) |
434 | self._create_scenario(admin, None) |
435 | - self.assertNotEqual(None, self.old_link) |
436 | + self.assertOldLinkPresent() |
437 | self.assertNewLinksMissing() |
438 | |
439 | def test_subscribe_link_feature_flag_on_admin(self): |
440 | @@ -550,12 +561,11 @@ |
441 | self.assertNewLinksPresent() |
442 | |
443 | |
444 | -class TestProductSeriesMilestoneViewStructSubs( |
445 | - TestProductMilestoneViewStructSubs): |
446 | +class ProductSeriesMilestoneView(ProductMilestoneView): |
447 | """Test structural subscriptions on the product series milestones.""" |
448 | |
449 | def setUp(self): |
450 | - super(TestProductSeriesMilestoneViewStructSubs, self).setUp() |
451 | + super(ProductSeriesMilestoneView, self).setUp() |
452 | self.productseries = self.factory.makeProductSeries() |
453 | with person_logged_in(self.productseries.product.owner): |
454 | self.productseries.product.official_malone = True |
455 | @@ -563,27 +573,313 @@ |
456 | self.target = self.factory.makeMilestone( |
457 | productseries=self.productseries) |
458 | |
459 | +# Tests for when the IStructuralSubscriptionTarget does not use Launchpad for |
460 | +# bug tracking. In those cases the links should not be shown. |
461 | + |
462 | +class ProductDoesNotUseLPView(ProductView): |
463 | + """Test structural subscriptions on the product view.""" |
464 | + |
465 | + def setUp(self): |
466 | + super(ProductDoesNotUseLPView, self).setUp() |
467 | + self.target = self.factory.makeProduct(official_malone=False) |
468 | + |
469 | + def test_subscribe_link_feature_flag_on_owner(self): |
470 | + # Test the new subscription link. |
471 | + self._create_scenario(self.target.owner, 'on') |
472 | + self.assertOldLinkMissing() |
473 | + self.assertNewLinksMissing() |
474 | + |
475 | + def test_subscribe_link_feature_flag_on_user(self): |
476 | + self._create_scenario(self.regular_user, 'on') |
477 | + self.assertOldLinkMissing() |
478 | + self.assertNewLinksMissing() |
479 | + |
480 | + def test_subscribe_link_feature_flag_on_anonymous(self): |
481 | + self._create_scenario(ANONYMOUS, 'on') |
482 | + # The subscribe link is not shown to anonymous. |
483 | + self.assertOldLinkMissing() |
484 | + self.assertNewLinksMissing() |
485 | + |
486 | + |
487 | +class ProductDoesNotUseLPBugs(ProductDoesNotUseLPView): |
488 | + """Test structural subscriptions on the product bugs view.""" |
489 | + |
490 | + rootsite = 'bugs' |
491 | + view = '+bugs-index' |
492 | + |
493 | + def test_subscribe_link_feature_flag_off_owner(self): |
494 | + self._create_scenario(self.target.owner, None) |
495 | + self.assertOldLinkMissing() |
496 | + self.assertNewLinksMissing() |
497 | + |
498 | + def test_subscribe_link_feature_flag_off_user(self): |
499 | + self._create_scenario(self.regular_user, None) |
500 | + self.assertOldLinkMissing() |
501 | + self.assertNewLinksMissing() |
502 | + |
503 | + def test_subscribe_link_feature_flag_off_anonymous(self): |
504 | + self._create_scenario(ANONYMOUS, None) |
505 | + # The old subscribe link is actually shown to anonymous users but the |
506 | + # behavior has changed with the new link. |
507 | + self.assertOldLinkMissing() |
508 | + self.assertNewLinksMissing() |
509 | + |
510 | + |
511 | +class ProjectGroupDoesNotUseLPView(ProductDoesNotUseLPView): |
512 | + """Test structural subscriptions on the project group view.""" |
513 | + |
514 | + rootsite = None |
515 | + view = '+index' |
516 | + |
517 | + def setUp(self): |
518 | + super(ProjectGroupDoesNotUseLPView, self).setUp() |
519 | + self.target = self.factory.makeProject() |
520 | + self.factory.makeProduct( |
521 | + project=self.target, official_malone=False) |
522 | + |
523 | + |
524 | +class ProjectGroupDoesNotUseLPBugs(ProductDoesNotUseLPBugs): |
525 | + """Test structural subscriptions on the project group bugs view.""" |
526 | + |
527 | + rootsite = 'bugs' |
528 | + view = '+bugs' |
529 | + |
530 | + def setUp(self): |
531 | + super(ProjectGroupDoesNotUseLPBugs, self).setUp() |
532 | + self.target = self.factory.makeProject() |
533 | + self.factory.makeProduct( |
534 | + project=self.target, official_malone=False) |
535 | + |
536 | + |
537 | +class ProductSeriesDoesNotUseLPView(ProductDoesNotUseLPView): |
538 | + |
539 | + def setUp(self): |
540 | + super(ProductSeriesDoesNotUseLPView, self).setUp() |
541 | + product = self.factory.makeProduct(official_malone=False) |
542 | + self.target = self.factory.makeProductSeries(product=product) |
543 | + |
544 | + |
545 | +class ProductSeriesDoesNotUseLPBugs(ProductDoesNotUseLPView): |
546 | + |
547 | + def setUp(self): |
548 | + super(ProductSeriesDoesNotUseLPBugs, self).setUp() |
549 | + product = self.factory.makeProduct(official_malone=False) |
550 | + self.target = self.factory.makeProductSeries(product=product) |
551 | + |
552 | + |
553 | +class DistributionSourcePackageDoesNotUseLPView(ProductDoesNotUseLPView): |
554 | + """Test structural subscriptions on the distro src pkg view.""" |
555 | + |
556 | + def setUp(self): |
557 | + super(DistributionSourcePackageDoesNotUseLPView, self).setUp() |
558 | + distro = self.factory.makeDistribution() |
559 | + self.target = self.factory.makeDistributionSourcePackage( |
560 | + distribution=distro) |
561 | + self.regular_user = self.factory.makePerson() |
562 | + |
563 | + # DistributionSourcePackages do not have owners. |
564 | + test_subscribe_link_feature_flag_off_owner = None |
565 | + test_subscribe_link_feature_flag_on_owner = None |
566 | + |
567 | + |
568 | +class DistributionSourcePackageDoesNotUseLPBugs(ProductDoesNotUseLPBugs): |
569 | + """Test structural subscriptions on the distro src pkg bugs view.""" |
570 | + |
571 | + view = '+bugs' |
572 | + |
573 | + # DistributionSourcePackages do not have owners. |
574 | + test_subscribe_link_feature_flag_off_owner = None |
575 | + test_subscribe_link_feature_flag_on_owner = None |
576 | + |
577 | + |
578 | +class DistroDoesNotUseLPView(DistroView): |
579 | + |
580 | + def setUp(self): |
581 | + super(DistroDoesNotUseLPView, self).setUp() |
582 | + self.target = self.factory.makeDistribution() |
583 | + self.regular_user = self.factory.makePerson() |
584 | + |
585 | + def test_subscribe_link_feature_flag_on_admin(self): |
586 | + admin = getUtility(IPersonSet).getByEmail(ADMIN_EMAIL) |
587 | + self._create_scenario(admin, 'on') |
588 | + self.assertOldLinkMissing() |
589 | + self.assertNewLinksMissing() |
590 | + |
591 | + def test_subscribe_link_feature_flag_on_bug_super(self): |
592 | + with celebrity_logged_in('admin'): |
593 | + admin = getUtility(ILaunchBag).user |
594 | + self.target.setBugSupervisor( |
595 | + self.regular_user, admin) |
596 | + self._create_scenario(self.regular_user, 'on') |
597 | + self.assertOldLinkMissing() |
598 | + self.assertNewLinksMissing() |
599 | + |
600 | + def test_subscribe_link_feature_flag_on_user_no_bug_super(self): |
601 | + self._create_scenario(self.regular_user, 'on') |
602 | + self.assertOldLinkMissing() |
603 | + self.assertNewLinksMissing() |
604 | + |
605 | + def test_subscribe_link_feature_flag_on_owner(self): |
606 | + # Test the new subscription link. |
607 | + self._create_scenario(self.target.owner, 'on') |
608 | + self.assertOldLinkMissing() |
609 | + self.assertNewLinksMissing() |
610 | + |
611 | + def test_subscribe_link_feature_flag_on_user(self): |
612 | + self._create_scenario(self.regular_user, 'on') |
613 | + self.assertOldLinkMissing() |
614 | + self.assertNewLinksMissing() |
615 | + |
616 | + def test_subscribe_link_feature_flag_on_anonymous(self): |
617 | + self._create_scenario(ANONYMOUS, 'on') |
618 | + # The subscribe link is not shown to anonymous. |
619 | + self.assertOldLinkMissing() |
620 | + self.assertNewLinksMissing() |
621 | + |
622 | + |
623 | +class DistroDoesNotUseLPBugs(DistroDoesNotUseLPView): |
624 | + rootsite = 'bugs' |
625 | + view = '+bugs-index' |
626 | + |
627 | + def test_subscribe_link_feature_flag_off_owner(self): |
628 | + self._create_scenario(self.target.owner, None) |
629 | + self.assertOldLinkMissing() |
630 | + self.assertNewLinksMissing() |
631 | + |
632 | + def test_subscribe_link_feature_flag_off_user(self): |
633 | + self._create_scenario(self.regular_user, None) |
634 | + self.assertOldLinkMissing() |
635 | + self.assertNewLinksMissing() |
636 | + |
637 | + def test_subscribe_link_feature_flag_off_anonymous(self): |
638 | + self._create_scenario(ANONYMOUS, None) |
639 | + # The old subscribe link is actually shown to anonymous users but the |
640 | + # behavior has changed with the new link. |
641 | + self.assertOldLinkMissing() |
642 | + self.assertNewLinksMissing() |
643 | + |
644 | + |
645 | +class DistroMilestoneDoesNotUseLPView(DistroMilestoneView): |
646 | + |
647 | + def setUp(self): |
648 | + super(DistroMilestoneDoesNotUseLPView, self).setUp() |
649 | + with person_logged_in(self.distro.owner): |
650 | + self.distro.official_malone = False |
651 | + |
652 | + def test_subscribe_link_feature_flag_on_admin(self): |
653 | + admin = getUtility(IPersonSet).getByEmail(ADMIN_EMAIL) |
654 | + self._create_scenario(admin, 'on') |
655 | + self.assertOldLinkMissing() |
656 | + self.assertNewLinksMissing() |
657 | + |
658 | + def test_subscribe_link_feature_flag_on_bug_super(self): |
659 | + with celebrity_logged_in('admin'): |
660 | + admin = getUtility(ILaunchBag).user |
661 | + self.distro.setBugSupervisor( |
662 | + self.regular_user, admin) |
663 | + self._create_scenario(self.regular_user, 'on') |
664 | + self.assertOldLinkMissing() |
665 | + self.assertNewLinksMissing() |
666 | + |
667 | + def test_subscribe_link_feature_flag_on_user_no_bug_super(self): |
668 | + self._create_scenario(self.regular_user, 'on') |
669 | + self.assertOldLinkMissing() |
670 | + self.assertNewLinksMissing() |
671 | + |
672 | + def test_subscribe_link_feature_flag_on_owner(self): |
673 | + # Test the new subscription link. |
674 | + self._create_scenario(self.distro.owner, 'on') |
675 | + self.assertOldLinkMissing() |
676 | + self.assertNewLinksMissing() |
677 | + |
678 | + def test_subscribe_link_feature_flag_on_user(self): |
679 | + self._create_scenario(self.regular_user, 'on') |
680 | + self.assertOldLinkMissing() |
681 | + self.assertNewLinksMissing() |
682 | + |
683 | + def test_subscribe_link_feature_flag_on_anonymous(self): |
684 | + self._create_scenario(ANONYMOUS, 'on') |
685 | + # The subscribe link is not shown to anonymous. |
686 | + self.assertOldLinkMissing() |
687 | + self.assertNewLinksMissing() |
688 | + |
689 | + def test_subscribe_link_feature_flag_on_user_with_bug_super(self): |
690 | + with celebrity_logged_in('admin'): |
691 | + admin = getUtility(ILaunchBag).user |
692 | + supervisor = self.factory.makePerson() |
693 | + self.distro.setBugSupervisor( |
694 | + supervisor, admin) |
695 | + self._create_scenario(self.regular_user, 'on') |
696 | + self.assertOldLinkMissing() |
697 | + self.assertNewLinksMissing() |
698 | + |
699 | + |
700 | +class ProductMilestoneDoesNotUseLPView(ProductMilestoneView): |
701 | + |
702 | + def setUp(self): |
703 | + BrowserTestCase.setUp(self) |
704 | + self.product = self.factory.makeProduct() |
705 | + with person_logged_in(self.product.owner): |
706 | + self.product.official_malone = False |
707 | + self.target = self.factory.makeMilestone( |
708 | + name='1.0', product=self.product) |
709 | + self.regular_user = self.factory.makePerson() |
710 | + |
711 | + def test_subscribe_link_feature_flag_off_owner(self): |
712 | + self._create_scenario(self.product.owner, None) |
713 | + # The presence of the old link is certainly a mistake since the |
714 | + # product does not use Launchpad for bug tracking. |
715 | + self.assertOldLinkPresent() |
716 | + self.assertNewLinksMissing() |
717 | + |
718 | + def test_subscribe_link_feature_flag_off_user(self): |
719 | + self._create_scenario(self.regular_user, None) |
720 | + # The presence of the old link is certainly a mistake since the |
721 | + # product does not use Launchpad for bug tracking. |
722 | + self.assertOldLinkPresent() |
723 | + self.assertNewLinksMissing() |
724 | + |
725 | + def test_subscribe_link_feature_flag_off_anonymous(self): |
726 | + self._create_scenario(ANONYMOUS, None) |
727 | + # The presence of the old link is certainly a mistake since the |
728 | + # product does not use Launchpad for bug tracking. |
729 | + self.assertOldLinkPresent() |
730 | + self.assertNewLinksMissing() |
731 | + |
732 | + def test_subscribe_link_feature_flag_off_admin(self): |
733 | + admin = getUtility(IPersonSet).getByEmail(ADMIN_EMAIL) |
734 | + self._create_scenario(admin, None) |
735 | + # The presence of the old link is certainly a mistake since the |
736 | + # product does not use Launchpad for bug tracking. |
737 | + self.assertOldLinkPresent() |
738 | + self.assertNewLinksMissing() |
739 | + |
740 | + def test_subscribe_link_feature_flag_on_admin(self): |
741 | + from lp.testing.sampledata import ADMIN_EMAIL |
742 | + admin = getUtility(IPersonSet).getByEmail(ADMIN_EMAIL) |
743 | + self._create_scenario(admin, 'on') |
744 | + self.assertOldLinkMissing() |
745 | + self.assertNewLinksMissing() |
746 | + |
747 | + def test_subscribe_link_feature_flag_on_owner(self): |
748 | + self._create_scenario(self.product.owner, 'on') |
749 | + self.assertOldLinkMissing() |
750 | + self.assertNewLinksMissing() |
751 | + |
752 | + |
753 | +class CustomTestLoader(unittest.TestLoader): |
754 | + """A test loader that avoids running tests from a base class.""" |
755 | + |
756 | + def getTestCaseNames(self, testCaseClass): |
757 | + # If we're asked about which tests to run for _TestStructSubs, reply |
758 | + # with an empty list. |
759 | + if testCaseClass is _TestStructSubs: |
760 | + return [] |
761 | + else: |
762 | + return super(CustomTestLoader, self).getTestCaseNames( |
763 | + testCaseClass) |
764 | + |
765 | |
766 | def test_suite(): |
767 | """Return the `IStructuralSubscriptionTarget` TestSuite.""" |
768 | - |
769 | - # Manually construct the test suite to avoid having tests from the base |
770 | - # class _TestStructSubs run. |
771 | - suite = unittest.TestSuite() |
772 | - suite.addTest(unittest.makeSuite(TestProductViewStructSubs)) |
773 | - suite.addTest(unittest.makeSuite(TestProductBugsStructSubs)) |
774 | - suite.addTest(unittest.makeSuite(TestProductSeriesViewStructSubs)) |
775 | - suite.addTest(unittest.makeSuite(TestProductSeriesBugsStructSubs)) |
776 | - suite.addTest(unittest.makeSuite(TestProjectGroupViewStructSubs)) |
777 | - suite.addTest(unittest.makeSuite(TestProjectGroupBugsStructSubs)) |
778 | - suite.addTest(unittest.makeSuite( |
779 | - TestDistributionSourcePackageViewStructSubs)) |
780 | - suite.addTest(unittest.makeSuite( |
781 | - TestDistributionSourcePackageBugsStructSubs)) |
782 | - suite.addTest(unittest.makeSuite(TestDistroViewStructSubs)) |
783 | - suite.addTest(unittest.makeSuite(TestDistroBugsStructSubs)) |
784 | - suite.addTest(unittest.makeSuite(TestDistroMilestoneViewStructSubs)) |
785 | - suite.addTest(unittest.makeSuite(TestProductMilestoneViewStructSubs)) |
786 | - suite.addTest(unittest.makeSuite( |
787 | - TestProductSeriesMilestoneViewStructSubs)) |
788 | - return suite |
789 | + return CustomTestLoader().loadTestsFromName(__name__) |
790 | |
791 | === modified file 'lib/lp/registry/templates/distribution-index.pt' |
792 | --- lib/lp/registry/templates/distribution-index.pt 2011-04-11 00:34:52 +0000 |
793 | +++ lib/lp/registry/templates/distribution-index.pt 2011-04-13 01:26:33 +0000 |
794 | @@ -8,16 +8,19 @@ |
795 | |
796 | <head> |
797 | <tal:head-epilogue metal:fill-slot="head_epilogue"> |
798 | - <script type="text/javascript" |
799 | - tal:condition=" |
800 | - request/features/malone.advanced-structural-subscriptions.enabled"> |
801 | - LPS.use('lp.registry.structural_subscription', function(Y) { |
802 | - var module = Y.lp.registry.structural_subscription; |
803 | - Y.on('domready', function() { |
804 | - module.setup({content_box: "#structural-subscription-content-box"}); |
805 | - }); |
806 | - }); |
807 | - </script> |
808 | + <tal:uses_launchpad_bugtracker |
809 | + condition="context/bug_tracking_usage/enumvalue:LAUNCHPAD"> |
810 | + <script type="text/javascript" |
811 | + tal:condition=" |
812 | + request/features/malone.advanced-structural-subscriptions.enabled"> |
813 | + LPS.use('lp.registry.structural_subscription', function(Y) { |
814 | + var module = Y.lp.registry.structural_subscription; |
815 | + Y.on('domready', function() { |
816 | + module.setup({content_box: "#structural-subscription-content-box"}); |
817 | + }); |
818 | + }); |
819 | + </script> |
820 | + </tal:uses_launchpad_bugtracker> |
821 | </tal:head-epilogue> |
822 | </head> |
823 | |
824 | |
825 | === modified file 'lib/lp/registry/templates/distributionsourcepackage-index.pt' |
826 | --- lib/lp/registry/templates/distributionsourcepackage-index.pt 2011-04-05 16:05:15 +0000 |
827 | +++ lib/lp/registry/templates/distributionsourcepackage-index.pt 2011-04-13 01:26:33 +0000 |
828 | @@ -10,16 +10,19 @@ |
829 | <body> |
830 | |
831 | <metal:block fill-slot="head_epilogue"> |
832 | - <script type="text/javascript" |
833 | - tal:condition=" |
834 | - request/features/malone.advanced-structural-subscriptions.enabled"> |
835 | - LPS.use('lp.registry.structural_subscription', function(Y) { |
836 | - var module = Y.lp.registry.structural_subscription; |
837 | - Y.on('domready', function() { |
838 | - module.setup({content_box: "#structural-subscription-content-box"}); |
839 | - }); |
840 | - }); |
841 | - </script> |
842 | + <tal:uses_launchpad_bugtracker |
843 | + condition="context/distribution/bug_tracking_usage/enumvalue:LAUNCHPAD"> |
844 | + <script type="text/javascript" |
845 | + tal:condition=" |
846 | + request/features/malone.advanced-structural-subscriptions.enabled"> |
847 | + LPS.use('lp.registry.structural_subscription', function(Y) { |
848 | + var module = Y.lp.registry.structural_subscription; |
849 | + Y.on('domready', function() { |
850 | + module.setup({content_box: "#structural-subscription-content-box"}); |
851 | + }); |
852 | + }); |
853 | + </script> |
854 | + </tal:uses_launchpad_bugtracker> |
855 | </metal:block> |
856 | |
857 | <tal:side metal:fill-slot="side"> |
858 | |
859 | === modified file 'lib/lp/registry/templates/distroseries-index.pt' |
860 | --- lib/lp/registry/templates/distroseries-index.pt 2011-03-30 21:38:03 +0000 |
861 | +++ lib/lp/registry/templates/distroseries-index.pt 2011-04-13 01:26:33 +0000 |
862 | @@ -13,16 +13,19 @@ |
863 | <script id="milestone-script" type="text/javascript" |
864 | tal:condition="context/menu:overview/create_milestone/enabled" |
865 | tal:content="view/register_milestone_script"></script> |
866 | - <script type="text/javascript" |
867 | - tal:condition=" |
868 | - request/features/malone.advanced-structural-subscriptions.enabled"> |
869 | - LPS.use('lp.registry.structural_subscription', function(Y) { |
870 | - var module = Y.lp.registry.structural_subscription; |
871 | - Y.on('domready', function() { |
872 | - module.setup({content_box: "#structural-subscription-content-box"}); |
873 | - }); |
874 | - }); |
875 | - </script> |
876 | + <tal:uses_launchpad_bugtracker |
877 | + condition="context/bug_tracking_usage/enumvalue:LAUNCHPAD"> |
878 | + <script type="text/javascript" |
879 | + tal:condition=" |
880 | + request/features/malone.advanced-structural-subscriptions.enabled"> |
881 | + LPS.use('lp.registry.structural_subscription', function(Y) { |
882 | + var module = Y.lp.registry.structural_subscription; |
883 | + Y.on('domready', function() { |
884 | + module.setup({content_box: "#structural-subscription-content-box"}); |
885 | + }); |
886 | + }); |
887 | + </script> |
888 | + </tal:uses_launchpad_bugtracker> |
889 | </metal:block> |
890 | |
891 | <tal:heading metal:fill-slot="heading"> |
892 | |
893 | === modified file 'lib/lp/registry/templates/milestone-index.pt' |
894 | --- lib/lp/registry/templates/milestone-index.pt 2011-03-29 22:34:04 +0000 |
895 | +++ lib/lp/registry/templates/milestone-index.pt 2011-04-13 01:26:33 +0000 |
896 | @@ -13,16 +13,19 @@ |
897 | background: #fff; |
898 | } |
899 | </style> |
900 | - <script type="text/javascript" |
901 | - tal:condition=" |
902 | - request/features/malone.advanced-structural-subscriptions.enabled"> |
903 | - LPS.use('lp.registry.structural_subscription', function(Y) { |
904 | - var module = Y.lp.registry.structural_subscription; |
905 | - Y.on('domready', function() { |
906 | - module.setup({content_box: "#structural-subscription-content-box"}); |
907 | - }); |
908 | - }); |
909 | - </script> |
910 | + <tal:uses_launchpad_bugtracker |
911 | + condition="context/target/bug_tracking_usage/enumvalue:LAUNCHPAD"> |
912 | + <script type="text/javascript" |
913 | + tal:condition=" |
914 | + request/features/malone.advanced-structural-subscriptions.enabled"> |
915 | + LPS.use('lp.registry.structural_subscription', function(Y) { |
916 | + var module = Y.lp.registry.structural_subscription; |
917 | + Y.on('domready', function() { |
918 | + module.setup({content_box: "#structural-subscription-content-box"}); |
919 | + }); |
920 | + }); |
921 | + </script> |
922 | + </tal:uses_launchpad_bugtracker> |
923 | </tal:head-epilogue> |
924 | |
925 | <body> |
926 | |
927 | === modified file 'lib/lp/registry/templates/product-index.pt' |
928 | --- lib/lp/registry/templates/product-index.pt 2011-03-29 22:34:04 +0000 |
929 | +++ lib/lp/registry/templates/product-index.pt 2011-04-13 01:26:33 +0000 |
930 | @@ -31,17 +31,19 @@ |
931 | div.collapsible, div.collapsed {display: block;} |
932 | </style> |
933 | </noscript> |
934 | - |
935 | - <script type="text/javascript" |
936 | - tal:condition=" |
937 | - request/features/malone.advanced-structural-subscriptions.enabled"> |
938 | - LPS.use('lp.registry.structural_subscription', function(Y) { |
939 | - var module = Y.lp.registry.structural_subscription; |
940 | - Y.on('domready', function() { |
941 | - module.setup({content_box: "#structural-subscription-content-box"}); |
942 | - }); |
943 | - }); |
944 | - </script> |
945 | + <tal:uses_launchpad_bugtracker |
946 | + condition="context/bug_tracking_usage/enumvalue:LAUNCHPAD"> |
947 | + <script type="text/javascript" |
948 | + tal:condition=" |
949 | + request/features/malone.advanced-structural-subscriptions.enabled"> |
950 | + LPS.use('lp.registry.structural_subscription', function(Y) { |
951 | + var module = Y.lp.registry.structural_subscription; |
952 | + Y.on('domready', function() { |
953 | + module.setup({content_box: "#structural-subscription-content-box"}); |
954 | + }); |
955 | + }); |
956 | + </script> |
957 | + </tal:uses_launchpad_bugtracker> |
958 | </tal:head-epilogue> |
959 | </head> |
960 | |
961 | |
962 | === modified file 'lib/lp/registry/templates/productseries-index.pt' |
963 | --- lib/lp/registry/templates/productseries-index.pt 2011-04-04 18:51:17 +0000 |
964 | +++ lib/lp/registry/templates/productseries-index.pt 2011-04-13 01:26:33 +0000 |
965 | @@ -14,16 +14,19 @@ |
966 | <script id="milestone-script" type="text/javascript" |
967 | tal:condition="context/menu:overview/create_milestone/enabled" |
968 | tal:content="view/register_milestone_script"></script> |
969 | - <script type="text/javascript" |
970 | - tal:condition=" |
971 | - request/features/malone.advanced-structural-subscriptions.enabled"> |
972 | - LPS.use('lp.registry.structural_subscription', function(Y) { |
973 | - var module = Y.lp.registry.structural_subscription; |
974 | - Y.on('domready', function() { |
975 | - module.setup({content_box: "#structural-subscription-content-box"}); |
976 | - }); |
977 | - }); |
978 | - </script> |
979 | + <tal:uses_launchpad_bugtracker |
980 | + condition="context/bug_tracking_usage/enumvalue:LAUNCHPAD"> |
981 | + <script type="text/javascript" |
982 | + tal:condition=" |
983 | + request/features/malone.advanced-structural-subscriptions.enabled"> |
984 | + LPS.use('lp.registry.structural_subscription', function(Y) { |
985 | + var module = Y.lp.registry.structural_subscription; |
986 | + Y.on('domready', function() { |
987 | + module.setup({content_box: "#structural-subscription-content-box"}); |
988 | + }); |
989 | + }); |
990 | + </script> |
991 | + </tal:uses_launchpad_bugtracker> |
992 | </metal:block> |
993 | |
994 | <tal:heading metal:fill-slot="heading"> |
995 | |
996 | === modified file 'lib/lp/registry/templates/project-index.pt' |
997 | --- lib/lp/registry/templates/project-index.pt 2011-03-29 22:34:04 +0000 |
998 | +++ lib/lp/registry/templates/project-index.pt 2011-04-13 01:26:33 +0000 |
999 | @@ -9,16 +9,19 @@ |
1000 | |
1001 | <head> |
1002 | <tal:head-epilogue metal:fill-slot="head_epilogue"> |
1003 | - <script type="text/javascript" |
1004 | - tal:condition=" |
1005 | - request/features/malone.advanced-structural-subscriptions.enabled"> |
1006 | - LPS.use('lp.registry.structural_subscription', function(Y) { |
1007 | - var module = Y.lp.registry.structural_subscription; |
1008 | - Y.on('domready', function() { |
1009 | - module.setup({content_box: "#structural-subscription-content-box"}); |
1010 | - }); |
1011 | - }); |
1012 | - </script> |
1013 | + <tal:uses_launchpad_bugtracker |
1014 | + condition="context/bug_tracking_usage/enumvalue:LAUNCHPAD"> |
1015 | + <script type="text/javascript" |
1016 | + tal:condition=" |
1017 | + request/features/malone.advanced-structural-subscriptions.enabled"> |
1018 | + LPS.use('lp.registry.structural_subscription', function(Y) { |
1019 | + var module = Y.lp.registry.structural_subscription; |
1020 | + Y.on('domready', function() { |
1021 | + module.setup({content_box: "#structural-subscription-content-box"}); |
1022 | + }); |
1023 | + }); |
1024 | + </script> |
1025 | + </tal:uses_launchpad_bugtracker> |
1026 | </tal:head-epilogue> |
1027 | </head> |
1028 |
We discussed the accidentally- included message argument on line 76 of
the diff in IRC.
I would add failure messages to the asserts inside your custom assert ssing, assertOldLinkPr esent, issing, assertNewLinksP resent.
methods: assertOldLinkMi
assertNewLinksM
Skipping DistroView.setUp on line 345 of the diff and calling .setUp instead confused me. If I replace it with a call
BrowserTestCase
to DistroView.setUp the tests still pass.
Also, you didn't start it, but the manual test suite construction in pastebin. ubuntu. com/593155/).
test_suite is kinda ugly and brittle (a test could easily be dropped
from the list and not noticed). Here's a change that uses the standard
unittest test loader but ignores test cases from the base class that we
want to avoid (also available at http://
=== modified file 'lib/lp/ registry/ browser/ tests/test_ subscription_ links.py' registry/ browser/ tests/test_ subscription_ links.py 2011-04-12 14:49:43 +0000 registry/ browser/ tests/test_ subscription_ links.py 2011-04-12 14:49:49 +0000
self. assertNewLinksM issing( )
--- lib/lp/
+++ lib/lp/
@@ -855,40 +855,19 @@
+class CustomTestLoade r(unittest. TestLoader) : s(self, testCaseClass): tLoader, self).getTestCa seNames( scriptionTarget ` TestSuite.""" TestSuite( ) unittest. makeSuite( ProductView) ) unittest. makeSuite( ProductBugs) ) unittest. makeSuite( ProductSeriesVi ew)) unittest. makeSuite( ProductSeriesBu gs)) unittest. makeSuite( ProjectGroupVie w)) unittest. makeSuite( ProjectGroupBug s)) unittest. makeSuite( DistributionSou rcePackageView) ) unittest. makeSuite( DistributionSou rcePackageBugs) ) unittest. makeSuite( DistroView) ) unittest. makeSuite( DistroBugs) ) unittest. makeSuite( DistroMilestone View)) unittest. makeSuite( ProductMileston eView)) unittest. makeSuite( ProductSeriesMi lestoneView) ) unittest. makeSuite( ProductDoesNotU seLPView) ) unittest. makeSuite( ProductDoesNotU seLPBugs) ) unittest. makeSuite( ProductSeriesDo esNotUseLPView) ) unittest. makeSuite( ProductSeriesDo esNotUseLPBugs) ) unittest. makeSuite( ProjectGroupDoe sNotUseLPView) ) unittest. makeSuite( ProjectGroupDoe sNotUseLPBugs) ) unittest. makeSuite( rcePackageDoesN otUseLPView) ) unittest. makeSuite( rcePackageDoesN otUseLPBugs) ) unittest. makeSuite( Dis...
+ """A test loader that avoids running tests from a base class."""
+
+ def getTestCaseName
+ # If we're asked about which tests to run for _TestStructSubs, reply
+ # with an empty list.
+ if testCaseClass is _TestStructSubs:
+ return []
+ else:
+ return super(CustomTes
+ testCaseClass)
+
+
def test_suite():
"""Return the `IStructuralSub
-
- # Manually construct the test suite to avoid having tests from the base
- # class _TestStructSubs run.
- suite = unittest.
- suite.addTest(
- suite.addTest(
- suite.addTest(
- suite.addTest(
- suite.addTest(
- suite.addTest(
- suite.addTest(
- suite.addTest(
- suite.addTest(
- suite.addTest(
- suite.addTest(
- suite.addTest(
- suite.addTest(
-
- suite.addTest(
- suite.addTest(
- suite.addTest(
- suite.addTest(
- suite.addTest(
- suite.addTest(
- suite.addTest(
- DistributionSou
- suite.addTest(
- DistributionSou
- suite.addTest(