Merge lp:~gary/launchpad/bug723999-2a into lp:launchpad

Proposed by Gary Poster
Status: Merged
Merged at revision: 12548
Proposed branch: lp:~gary/launchpad/bug723999-2a
Merge into: lp:launchpad
Diff against target: 472 lines (+106/-99)
3 files modified
lib/lp/bugs/interfaces/structuralsubscription.py (+0/-8)
lib/lp/bugs/model/structuralsubscription.py (+39/-27)
lib/lp/bugs/tests/test_structuralsubscriptiontarget.py (+67/-64)
To merge this branch: bzr merge lp:~gary/launchpad/bug723999-2a
Reviewer Review Type Date Requested Status
Benji York (community) code Approve
Review via email: mp+52427@code.launchpad.net

Description of the change

This MP is one of several I'll be making to clean up my work on bug723999. I'm dividing up the work to try and make it easier to review.

This branch is about removing the getSubscriptionsForBugTask method on bug targets. It only had existed after my previous work on bug723999 because of tests that I didn't change because of branch size issues earlier.

I replace it with the get_structural_subscribers function. The get_structural_subscribers_for_bugtasks function remains as a wrapper for get_structural_subscribers (again, because of branch review size limitations); it will disappear in subsequent branches, leaving only get_structural_subscribers. As you can tell from the wrapper function, we only use this functionality in LP by either passing a list of a single bugtask, or all of the bugtasks in a bug. I'll be changing the rest of LP to explicitly do that in a future branch.

I adapted the tests to use the new function. Unfortunately, they are in the wrong module, because this code no longer has anything to do with targets directly. I will move the tests to test_structuralsubscription.py in a subsequent branch.

make lint is happy.

Thank you

Gary

To post a comment you must log in.
Revision history for this message
Benji York (benji) wrote :

This branch looks fine, being primarily a mechanical transformation from one perspective to another.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/bugs/interfaces/structuralsubscription.py'
--- lib/lp/bugs/interfaces/structuralsubscription.py 2011-02-04 06:30:13 +0000
+++ lib/lp/bugs/interfaces/structuralsubscription.py 2011-03-07 15:46:18 +0000
@@ -14,10 +14,6 @@
14 'IStructuralSubscriptionTargetHelper',14 'IStructuralSubscriptionTargetHelper',
15 ]15 ]
1616
17from lazr.enum import (
18 DBEnumeratedType,
19 DBItem,
20 )
21from lazr.restful.declarations import (17from lazr.restful.declarations import (
22 call_with,18 call_with,
23 export_as_webservice_entry,19 export_as_webservice_entry,
@@ -41,7 +37,6 @@
41 )37 )
42from zope.schema import (38from zope.schema import (
43 Bool,39 Bool,
44 Choice,
45 Datetime,40 Datetime,
46 Int,41 Int,
47 )42 )
@@ -149,9 +144,6 @@
149 def userHasBugSubscriptions(user):144 def userHasBugSubscriptions(user):
150 """Is `user` subscribed, directly or via a team, to bug mail?"""145 """Is `user` subscribed, directly or via a team, to bug mail?"""
151146
152 def getSubscriptionsForBugTask(bug, level):
153 """Return subscriptions for a given `IBugTask` at `level`."""
154
155147
156class IStructuralSubscriptionTargetWrite(Interface):148class IStructuralSubscriptionTargetWrite(Interface):
157 """A Launchpad Structure allowing users to subscribe to it.149 """A Launchpad Structure allowing users to subscribe to it.
158150
=== modified file 'lib/lp/bugs/model/structuralsubscription.py'
--- lib/lp/bugs/model/structuralsubscription.py 2011-03-04 02:29:09 +0000
+++ lib/lp/bugs/model/structuralsubscription.py 2011-03-07 15:46:18 +0000
@@ -4,6 +4,7 @@
4__metaclass__ = type4__metaclass__ = type
5__all__ = [5__all__ = [
6 'get_all_structural_subscriptions',6 'get_all_structural_subscriptions',
7 'get_structural_subscribers',
7 'get_structural_subscribers_for_bugtasks',8 'get_structural_subscribers_for_bugtasks',
8 'get_structural_subscription_targets',9 'get_structural_subscription_targets',
9 'StructuralSubscription',10 'StructuralSubscription',
@@ -47,6 +48,8 @@
47from canonical.database.sqlbase import quote48from canonical.database.sqlbase import quote
48from canonical.launchpad.interfaces.launchpad import ILaunchpadCelebrities49from canonical.launchpad.interfaces.launchpad import ILaunchpadCelebrities
49from canonical.launchpad.interfaces.lpstorm import IStore50from canonical.launchpad.interfaces.lpstorm import IStore
51from lp.bugs.interfaces.bug import IBug
52from lp.bugs.interfaces.bugtask import IBugTask
50from lp.bugs.interfaces.structuralsubscription import (53from lp.bugs.interfaces.structuralsubscription import (
51 IStructuralSubscription,54 IStructuralSubscription,
52 IStructuralSubscriptionTarget,55 IStructuralSubscriptionTarget,
@@ -476,24 +479,6 @@
476 return True479 return True
477 return False480 return False
478481
479 def getSubscriptionsForBugTask(self, bugtask, level):
480 """See `IStructuralSubscriptionTarget`."""
481 # Note that this method does not take into account
482 # structural subscriptions without filters. Since it is only
483 # used for tests at this point, that's not a problem; moreover,
484 # we intend all structural subscriptions to have filters.
485 candidates, filter_id_query = (
486 _get_structural_subscription_filter_id_query(
487 bugtask.bug, [bugtask], level))
488 if not candidates:
489 return EmptyResultSet()
490 return IStore(StructuralSubscription).find(
491 StructuralSubscription,
492 BugSubscriptionFilter.structural_subscription_id ==
493 StructuralSubscription.id,
494 In(BugSubscriptionFilter.id,
495 filter_id_query)).config(distinct=True)
496
497482
498def get_structural_subscription_targets(bugtasks):483def get_structural_subscription_targets(bugtasks):
499 """Return (bugtask, target) pairs for each target of the bugtasks.484 """Return (bugtask, target) pairs for each target of the bugtasks.
@@ -551,7 +536,30 @@
551 *conditions)536 *conditions)
552537
553538
554def _get_structural_subscribers(candidates, filter_id_query, recipients):539def get_structural_subscribers(bug_or_bugtask, recipients, level):
540 """Return subscribers for bug or bugtask at level.
541
542 :param bug: a bug.
543 :param recipients: a BugNotificationRecipients object or None.
544 Populates if given.
545 :param level: a level from lp.bugs.enum.BugNotificationLevel.
546
547 Excludes structural subscriptions for people who are directly subscribed
548 to the bug."""
549 if IBug.providedBy(bug_or_bugtask):
550 bug = bug_or_bugtask
551 bugtasks = bug.bugtasks
552 elif IBugTask.providedBy(bug_or_bugtask):
553 bug = bug_or_bugtask.bug
554 bugtasks = [bug_or_bugtask]
555 else:
556 raise ValueError('First argument must be bug or bugtask')
557 # XXX gary 2011-03-03 bug 728818
558 # Once we no longer have structural subscriptions without filters in
559 # qastaging and production, _get_structural_subscription_filter_id_query
560 # can just return the query, and leave the candidates out of it.
561 candidates, filter_id_query = (
562 _get_structural_subscription_filter_id_query(bug, bugtasks, level))
555 if not candidates:563 if not candidates:
556 return EmptyResultSet()564 return EmptyResultSet()
557 # This is here because of a circular import.565 # This is here because of a circular import.
@@ -601,22 +609,26 @@
601 level=None):609 level=None):
602 """Return subscribers for structural filters for the bugtasks at "level".610 """Return subscribers for structural filters for the bugtasks at "level".
603611
604 :param bugtasks: an iterable of bugtasks. All must be for the same bug.612 :param bugtasks: an iterable of bugtasks. Should be a single bugtask, or
613 all of the bugtasks from one bug.
605 :param recipients: a BugNotificationRecipients object or None.614 :param recipients: a BugNotificationRecipients object or None.
606 Populates if given.615 Populates if given.
607 :param level: a level from lp.bugs.enum.BugNotificationLevel.616 :param level: a level from lp.bugs.enum.BugNotificationLevel.
608617
609 Excludes structural subscriptions for people who are directly subscribed618 Excludes structural subscriptions for people who are directly subscribed
610 to the bug."""619 to the bug."""
620 bugtasks = list(bugtasks)
611 if not bugtasks:621 if not bugtasks:
612 return EmptyResultSet()622 return EmptyResultSet()
613 bugs = set(bugtask.bug for bugtask in bugtasks)623 if len(bugtasks) == 1:
614 if len(bugs) > 1:624 target = bugtasks[0]
615 raise NotImplementedError('Each bugtask must be from the same bug.')625 else:
616 bug = bugs.pop()626 target = bugtasks[0].bug
617 candidates, query = _get_structural_subscription_filter_id_query(627 if target.bugtasks != bugtasks:
618 bug, bugtasks, level)628 raise NotImplementedError(
619 return _get_structural_subscribers(candidates, query, recipients)629 'bugtasks must be one, or the full set of bugtasks from one '
630 'bug')
631 return get_structural_subscribers(target, recipients, level)
620632
621633
622class ArrayAgg(NamedFunc):634class ArrayAgg(NamedFunc):
623635
=== modified file 'lib/lp/bugs/tests/test_structuralsubscriptiontarget.py'
--- lib/lp/bugs/tests/test_structuralsubscriptiontarget.py 2011-03-01 18:58:40 +0000
+++ lib/lp/bugs/tests/test_structuralsubscriptiontarget.py 2011-03-07 15:46:18 +0000
@@ -37,7 +37,10 @@
37 IStructuralSubscriptionTarget,37 IStructuralSubscriptionTarget,
38 IStructuralSubscriptionTargetHelper,38 IStructuralSubscriptionTargetHelper,
39 )39 )
40from lp.bugs.model.structuralsubscription import StructuralSubscription40from lp.bugs.model.structuralsubscription import (
41 get_structural_subscribers,
42 StructuralSubscription,
43 )
41from lp.bugs.tests.test_bugtarget import bugtarget_filebug44from lp.bugs.tests.test_bugtarget import bugtarget_filebug
42from lp.registry.errors import (45from lp.registry.errors import (
43 DeleteSubscriptionError,46 DeleteSubscriptionError,
@@ -194,98 +197,98 @@
194 self.ordinary_subscriber, self.ordinary_subscriber)197 self.ordinary_subscriber, self.ordinary_subscriber)
195 self.initial_filter = self.subscription.bug_filters[0]198 self.initial_filter = self.subscription.bug_filters[0]
196199
197 def assertSubscriptions(200 def assertSubscribers(
198 self, expected_subscriptions, level=BugNotificationLevel.NOTHING):201 self, expected_subscribers, level=BugNotificationLevel.NOTHING):
199 observed_subscriptions = list(202 observed_subscribers = list(
200 self.target.getSubscriptionsForBugTask(self.bugtask, level))203 get_structural_subscribers(self.bugtask, None, level))
201 self.assertEqual(expected_subscriptions, observed_subscriptions)204 self.assertEqual(expected_subscribers, observed_subscribers)
202205
203 def test_getSubscriptionsForBugTask(self):206 def test_getStructuralSubscribers(self):
204 # If no one has a filtered subscription for the given bug, the result207 # If no one has a filtered subscription for the given bug, the result
205 # of getSubscriptionsForBugTask() is the same as for208 # of get_structural_subscribers() is the same as for
206 # getSubscriptions().209 # the set of people from each subscription in getSubscriptions().
207 subscriptions = self.target.getSubscriptions()210 subscriptions = self.target.getSubscriptions()
208 self.assertSubscriptions(list(subscriptions))211 self.assertSubscribers([sub.subscriber for sub in subscriptions])
209212
210 def test_getSubscriptionsForBugTask_with_filter_on_status(self):213 def test_getStructuralSubscribers_with_filter_on_status(self):
211 # If a status filter exists for a subscription, the result of214 # If a status filter exists for a subscription, the result of
212 # getSubscriptionsForBugTask() may be a subset of getSubscriptions().215 # get_structural_subscribers() may be a subset of getSubscriptions().
213216
214 # Without any filters the subscription is found.217 # Without any filters the subscription is found.
215 self.assertSubscriptions([self.subscription])218 self.assertSubscribers([self.ordinary_subscriber])
216219
217 # Filter the subscription to bugs in the CONFIRMED state.220 # Filter the subscription to bugs in the CONFIRMED state.
218 self.initial_filter.statuses = [BugTaskStatus.CONFIRMED]221 self.initial_filter.statuses = [BugTaskStatus.CONFIRMED]
219222
220 # With the filter the subscription is not found.223 # With the filter the subscription is not found.
221 self.assertSubscriptions([])224 self.assertSubscribers([])
222225
223 # If the filter is adjusted, the subscription is found again.226 # If the filter is adjusted, the subscription is found again.
224 self.initial_filter.statuses = [self.bugtask.status]227 self.initial_filter.statuses = [self.bugtask.status]
225 self.assertSubscriptions([self.subscription])228 self.assertSubscribers([self.ordinary_subscriber])
226229
227 def test_getSubscriptionsForBugTask_with_filter_on_importance(self):230 def test_getStructuralSubscribers_with_filter_on_importance(self):
228 # If an importance filter exists for a subscription, the result of231 # If an importance filter exists for a subscription, the result of
229 # getSubscriptionsForBugTask() may be a subset of getSubscriptions().232 # get_structural_subscribers() may be a subset of getSubscriptions().
230233
231 # Without any filters the subscription is found.234 # Without any filters the subscription is found.
232 self.assertSubscriptions([self.subscription])235 self.assertSubscribers([self.ordinary_subscriber])
233236
234 # Filter the subscription to bugs in the CRITICAL state.237 # Filter the subscription to bugs in the CRITICAL state.
235 self.initial_filter.importances = [BugTaskImportance.CRITICAL]238 self.initial_filter.importances = [BugTaskImportance.CRITICAL]
236239
237 # With the filter the subscription is not found.240 # With the filter the subscription is not found.
238 self.assertSubscriptions([])241 self.assertSubscribers([])
239242
240 # If the filter is adjusted, the subscription is found again.243 # If the filter is adjusted, the subscription is found again.
241 self.initial_filter.importances = [self.bugtask.importance]244 self.initial_filter.importances = [self.bugtask.importance]
242 self.assertSubscriptions([self.subscription])245 self.assertSubscribers([self.ordinary_subscriber])
243246
244 def test_getSubscriptionsForBugTask_with_filter_on_level(self):247 def test_getStructuralSubscribers_with_filter_on_level(self):
245 # All structural subscriptions have a level for bug notifications248 # All structural subscriptions have a level for bug notifications
246 # which getSubscriptionsForBugTask() observes.249 # which get_structural_subscribers() observes.
247250
248 # Adjust the subscription level to METADATA.251 # Adjust the subscription level to METADATA.
249 self.initial_filter.bug_notification_level = (252 self.initial_filter.bug_notification_level = (
250 BugNotificationLevel.METADATA)253 BugNotificationLevel.METADATA)
251254
252 # The subscription is found when looking for NOTHING or above.255 # The subscription is found when looking for NOTHING or above.
253 self.assertSubscriptions(256 self.assertSubscribers(
254 [self.subscription], BugNotificationLevel.NOTHING)257 [self.ordinary_subscriber], BugNotificationLevel.NOTHING)
255 # The subscription is found when looking for METADATA or above.258 # The subscription is found when looking for METADATA or above.
256 self.assertSubscriptions(259 self.assertSubscribers(
257 [self.subscription], BugNotificationLevel.METADATA)260 [self.ordinary_subscriber], BugNotificationLevel.METADATA)
258 # The subscription is not found when looking for COMMENTS or above.261 # The subscription is not found when looking for COMMENTS or above.
259 self.assertSubscriptions(262 self.assertSubscribers(
260 [], BugNotificationLevel.COMMENTS)263 [], BugNotificationLevel.COMMENTS)
261264
262 def test_getSubscriptionsForBugTask_with_filter_include_any_tags(self):265 def test_getStructuralSubscribers_with_filter_include_any_tags(self):
263 # If a subscription filter has include_any_tags, a bug with one or266 # If a subscription filter has include_any_tags, a bug with one or
264 # more tags is matched.267 # more tags is matched.
265268
266 self.initial_filter.include_any_tags = True269 self.initial_filter.include_any_tags = True
267270
268 # Without any tags the subscription is not found.271 # Without any tags the subscription is not found.
269 self.assertSubscriptions([])272 self.assertSubscribers([])
270273
271 # With any tag the subscription is found.274 # With any tag the subscription is found.
272 self.bug.tags = ["foo"]275 self.bug.tags = ["foo"]
273 self.assertSubscriptions([self.subscription])276 self.assertSubscribers([self.ordinary_subscriber])
274277
275 def test_getSubscriptionsForBugTask_with_filter_exclude_any_tags(self):278 def test_getStructuralSubscribers_with_filter_exclude_any_tags(self):
276 # If a subscription filter has exclude_any_tags, only bugs with no279 # If a subscription filter has exclude_any_tags, only bugs with no
277 # tags are matched.280 # tags are matched.
278281
279 self.initial_filter.exclude_any_tags = True282 self.initial_filter.exclude_any_tags = True
280283
281 # Without any tags the subscription is found.284 # Without any tags the subscription is found.
282 self.assertSubscriptions([self.subscription])285 self.assertSubscribers([self.ordinary_subscriber])
283286
284 # With any tag the subscription is not found.287 # With any tag the subscription is not found.
285 self.bug.tags = ["foo"]288 self.bug.tags = ["foo"]
286 self.assertSubscriptions([])289 self.assertSubscribers([])
287290
288 def test_getSubscriptionsForBugTask_with_filter_for_any_tag(self):291 def test_getStructuralSubscribers_with_filter_for_any_tag(self):
289 # If a subscription filter specifies that any of one or more specific292 # If a subscription filter specifies that any of one or more specific
290 # tags must be present, bugs with any of those tags are matched.293 # tags must be present, bugs with any of those tags are matched.
291294
@@ -294,13 +297,13 @@
294 self.initial_filter.find_all_tags = False297 self.initial_filter.find_all_tags = False
295298
296 # Without either tag the subscription is not found.299 # Without either tag the subscription is not found.
297 self.assertSubscriptions([])300 self.assertSubscribers([])
298301
299 # With either tag the subscription is found.302 # With either tag the subscription is found.
300 self.bug.tags = ["bar", "baz"]303 self.bug.tags = ["bar", "baz"]
301 self.assertSubscriptions([self.subscription])304 self.assertSubscribers([self.ordinary_subscriber])
302305
303 def test_getSubscriptionsForBugTask_with_filter_for_all_tags(self):306 def test_getStructuralSubscribers_with_filter_for_all_tags(self):
304 # If a subscription filter specifies that all of one or more specific307 # If a subscription filter specifies that all of one or more specific
305 # tags must be present, bugs with all of those tags are matched.308 # tags must be present, bugs with all of those tags are matched.
306309
@@ -309,17 +312,17 @@
309 self.initial_filter.find_all_tags = True312 self.initial_filter.find_all_tags = True
310313
311 # Without either tag the subscription is not found.314 # Without either tag the subscription is not found.
312 self.assertSubscriptions([])315 self.assertSubscribers([])
313316
314 # Without only one of the required tags the subscription is not found.317 # Without only one of the required tags the subscription is not found.
315 self.bug.tags = ["foo"]318 self.bug.tags = ["foo"]
316 self.assertSubscriptions([])319 self.assertSubscribers([])
317320
318 # With both required tags the subscription is found.321 # With both required tags the subscription is found.
319 self.bug.tags = ["foo", "bar"]322 self.bug.tags = ["foo", "bar"]
320 self.assertSubscriptions([self.subscription])323 self.assertSubscribers([self.ordinary_subscriber])
321324
322 def test_getSubscriptionsForBugTask_with_filter_for_not_any_tag(self):325 def test_getStructuralSubscribers_with_filter_for_not_any_tag(self):
323 # If a subscription filter specifies that any of one or more specific326 # If a subscription filter specifies that any of one or more specific
324 # tags must not be present, bugs without any of those tags are327 # tags must not be present, bugs without any of those tags are
325 # matched.328 # matched.
@@ -329,26 +332,26 @@
329 self.initial_filter.find_all_tags = False332 self.initial_filter.find_all_tags = False
330333
331 # Without either tag the subscription is found.334 # Without either tag the subscription is found.
332 self.assertSubscriptions([self.subscription])335 self.assertSubscribers([self.ordinary_subscriber])
333336
334 # With both tags, the subscription is omitted.337 # With both tags, the subscription is omitted.
335 self.bug.tags = ["foo", "bar"]338 self.bug.tags = ["foo", "bar"]
336 self.assertSubscriptions([])339 self.assertSubscribers([])
337340
338 # With only one tag, the subscription is found again.341 # With only one tag, the subscription is found again.
339 self.bug.tags = ["foo"]342 self.bug.tags = ["foo"]
340 self.assertSubscriptions([self.subscription])343 self.assertSubscribers([self.ordinary_subscriber])
341344
342 # However, if find_all_tags is True, even a single excluded tag345 # However, if find_all_tags is True, even a single excluded tag
343 # causes the subscription to be skipped.346 # causes the subscription to be skipped.
344 self.initial_filter.find_all_tags = True347 self.initial_filter.find_all_tags = True
345 self.assertSubscriptions([])348 self.assertSubscribers([])
346349
347 # This is also true, of course, if the bug has both tags.350 # This is also true, of course, if the bug has both tags.
348 self.bug.tags = ["foo", "bar"]351 self.bug.tags = ["foo", "bar"]
349 self.assertSubscriptions([])352 self.assertSubscribers([])
350353
351 def test_getSubscriptionsForBugTask_with_filter_for_not_all_tags(self):354 def test_getStructuralSubscribers_with_filter_for_not_all_tags(self):
352 # If a subscription filter specifies that all of one or more specific355 # If a subscription filter specifies that all of one or more specific
353 # tags must not be present, bugs without all of those tags are356 # tags must not be present, bugs without all of those tags are
354 # matched.357 # matched.
@@ -358,64 +361,64 @@
358 self.initial_filter.find_all_tags = True361 self.initial_filter.find_all_tags = True
359362
360 # Without either tag the subscription is found.363 # Without either tag the subscription is found.
361 self.assertSubscriptions([self.subscription])364 self.assertSubscribers([self.ordinary_subscriber])
362365
363 # With only one of the excluded tags the subscription is not366 # With only one of the excluded tags the subscription is not
364 # found--we are saying that we want to find both an absence of foo367 # found--we are saying that we want to find both an absence of foo
365 # and an absence of bar, and yet foo exists.368 # and an absence of bar, and yet foo exists.
366 self.bug.tags = ["foo"]369 self.bug.tags = ["foo"]
367 self.assertSubscriptions([])370 self.assertSubscribers([])
368371
369 # With both tags the subscription is also not found.372 # With both tags the subscription is also not found.
370 self.bug.tags = ["foo", "bar"]373 self.bug.tags = ["foo", "bar"]
371 self.assertSubscriptions([])374 self.assertSubscribers([])
372375
373 def test_getSubscriptionsForBugTask_with_multiple_filters(self):376 def test_getStructuralSubscribers_with_multiple_filters(self):
374 # If multiple filters exist for a subscription, all filters must377 # If multiple filters exist for a subscription, all filters must
375 # match.378 # match.
376379
377 # Add the "foo" tag to the bug.380 # Add the "foo" tag to the bug.
378 self.bug.tags = ["foo"]381 self.bug.tags = ["foo"]
379 self.assertSubscriptions([self.subscription])382 self.assertSubscribers([self.ordinary_subscriber])
380383
381 # Filter the subscription to bugs in the CRITICAL state.384 # Filter the subscription to bugs in the CRITICAL state.
382 self.initial_filter.statuses = [BugTaskStatus.CONFIRMED]385 self.initial_filter.statuses = [BugTaskStatus.CONFIRMED]
383 self.initial_filter.importances = [BugTaskImportance.CRITICAL]386 self.initial_filter.importances = [BugTaskImportance.CRITICAL]
384387
385 # With the filter the subscription is not found.388 # With the filter the subscription is not found.
386 self.assertSubscriptions([])389 self.assertSubscribers([])
387390
388 # If the filter is adjusted to match status but not importance, the391 # If the filter is adjusted to match status but not importance, the
389 # subscription is still not found.392 # subscription is still not found.
390 self.initial_filter.statuses = [self.bugtask.status]393 self.initial_filter.statuses = [self.bugtask.status]
391 self.assertSubscriptions([])394 self.assertSubscribers([])
392395
393 # If the filter is adjusted to also match importance, the subscription396 # If the filter is adjusted to also match importance, the subscription
394 # is found again.397 # is found again.
395 self.initial_filter.importances = [self.bugtask.importance]398 self.initial_filter.importances = [self.bugtask.importance]
396 self.assertSubscriptions([self.subscription])399 self.assertSubscribers([self.ordinary_subscriber])
397400
398 # If the filter is given some tag criteria, the subscription is not401 # If the filter is given some tag criteria, the subscription is not
399 # found.402 # found.
400 self.initial_filter.tags = [u"-foo", u"bar", u"baz"]403 self.initial_filter.tags = [u"-foo", u"bar", u"baz"]
401 self.initial_filter.find_all_tags = False404 self.initial_filter.find_all_tags = False
402 self.assertSubscriptions([])405 self.assertSubscribers([])
403406
404 # After removing the "foo" tag and adding the "bar" tag, the407 # After removing the "foo" tag and adding the "bar" tag, the
405 # subscription is found.408 # subscription is found.
406 self.bug.tags = ["bar"]409 self.bug.tags = ["bar"]
407 self.assertSubscriptions([self.subscription])410 self.assertSubscribers([self.ordinary_subscriber])
408411
409 # Requiring that all tag criteria are fulfilled causes the412 # Requiring that all tag criteria are fulfilled causes the
410 # subscription to no longer be found.413 # subscription to no longer be found.
411 self.initial_filter.find_all_tags = True414 self.initial_filter.find_all_tags = True
412 self.assertSubscriptions([])415 self.assertSubscribers([])
413416
414 # After adding the "baz" tag, the subscription is found again.417 # After adding the "baz" tag, the subscription is found again.
415 self.bug.tags = ["bar", "baz"]418 self.bug.tags = ["bar", "baz"]
416 self.assertSubscriptions([self.subscription])419 self.assertSubscribers([self.ordinary_subscriber])
417420
418 def test_getSubscriptionsForBugTask_any_filter_is_a_match(self):421 def test_getStructuralSubscribers_any_filter_is_a_match(self):
419 # If a subscription has multiple filters, the subscription is selected422 # If a subscription has multiple filters, the subscription is selected
420 # when any filter is found to match. Put another way, the filters are423 # when any filter is found to match. Put another way, the filters are
421 # ORed together.424 # ORed together.
@@ -425,24 +428,24 @@
425 subscription_filter2.tags = [u"foo"]428 subscription_filter2.tags = [u"foo"]
426429
427 # With the filter the subscription is not found.430 # With the filter the subscription is not found.
428 self.assertSubscriptions([])431 self.assertSubscribers([])
429432
430 # If the bugtask is adjusted to match the criteria of the first filter433 # If the bugtask is adjusted to match the criteria of the first filter
431 # but not those of the second, the subscription is found.434 # but not those of the second, the subscription is found.
432 self.bugtask.transitionToStatus(435 self.bugtask.transitionToStatus(
433 BugTaskStatus.CONFIRMED, self.ordinary_subscriber)436 BugTaskStatus.CONFIRMED, self.ordinary_subscriber)
434 self.assertSubscriptions([self.subscription])437 self.assertSubscribers([self.ordinary_subscriber])
435438
436 # If the filter is adjusted to also match the criteria of the second439 # If the filter is adjusted to also match the criteria of the second
437 # filter, the subscription is still found.440 # filter, the subscription is still found.
438 self.bugtask.bug.tags = [u"foo"]441 self.bugtask.bug.tags = [u"foo"]
439 self.assertSubscriptions([self.subscription])442 self.assertSubscribers([self.ordinary_subscriber])
440443
441 # If the bugtask is adjusted to no longer match the criteria of the444 # If the bugtask is adjusted to no longer match the criteria of the
442 # first filter, the subscription is still found.445 # first filter, the subscription is still found.
443 self.bugtask.transitionToStatus(446 self.bugtask.transitionToStatus(
444 BugTaskStatus.INPROGRESS, self.ordinary_subscriber)447 BugTaskStatus.INPROGRESS, self.ordinary_subscriber)
445 self.assertSubscriptions([self.subscription])448 self.assertSubscribers([self.ordinary_subscriber])
446449
447450
448class TestStructuralSubscriptionForDistro(451class TestStructuralSubscriptionForDistro(