launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #01383
[Merge] lp:~allenap/launchpad/structural-subscriptions-with-filters-5 into lp:launchpad
Gavin Panella has proposed merging lp:~allenap/launchpad/structural-subscriptions-with-filters-5 into lp:launchpad with lp:~allenap/launchpad/structural-subscriptions-with-filters-4 as a prerequisite.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers): code
Related bugs:
#650991 Add getSubscriptionsForBug to IStructuralSubscriptionTarget
https://bugs.launchpad.net/bugs/650991
Make getSubscriptionsForBug() respect its level argument.
--
https://code.launchpad.net/~allenap/launchpad/structural-subscriptions-with-filters-5/+merge/37608
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~allenap/launchpad/structural-subscriptions-with-filters-5 into lp:launchpad.
=== modified file 'lib/lp/registry/model/structuralsubscription.py'
--- lib/lp/registry/model/structuralsubscription.py 2010-10-05 14:43:49 +0000
+++ lib/lp/registry/model/structuralsubscription.py 2010-10-05 14:43:50 +0000
@@ -516,10 +516,12 @@
]
conditions = [
- # There's no filter or ...
- Or(BugSubscriptionFilter.id == None,
- # there is a filter ...
- And(
+ StructuralSubscription.bug_notification_level >= level,
+ Or(
+ # There's no filter or ...
+ BugSubscriptionFilter.id == None,
+ # there is a filter and ...
+ And(
# there's no status filter, or there is a status filter
# and and it matches.
Or(BugSubscriptionFilterStatus.id == None,
=== modified file 'lib/lp/registry/tests/test_structuralsubscriptiontarget.py'
--- lib/lp/registry/tests/test_structuralsubscriptiontarget.py 2010-10-05 14:43:49 +0000
+++ lib/lp/registry/tests/test_structuralsubscriptiontarget.py 2010-10-05 14:43:50 +0000
@@ -247,6 +247,30 @@
bugtask.bug, BugNotificationLevel.NOTHING)
self.assertEqual([subscription], list(subscriptions_for_bug))
+ def test_getSubscriptionsForBug_with_filter_on_level(self):
+ # All structural subscriptions have a level for bug notifications
+ # which getSubscriptionsForBug() observes.
+ bugtask = self.makeBugTask()
+
+ # Create a new METADATA level subscription on self.target.
+ login_person(self.ordinary_subscriber)
+ subscription = self.target.addSubscription(
+ self.ordinary_subscriber, self.ordinary_subscriber)
+ subscription.bug_notification_level = BugNotificationLevel.METADATA
+
+ # The subscription is found when looking for NOTHING or above.
+ subscriptions_for_bug = self.target.getSubscriptionsForBug(
+ bugtask.bug, BugNotificationLevel.NOTHING)
+ self.assertEqual([subscription], list(subscriptions_for_bug))
+ # The subscription is found when looking for METADATA or above.
+ subscriptions_for_bug = self.target.getSubscriptionsForBug(
+ bugtask.bug, BugNotificationLevel.METADATA)
+ self.assertEqual([subscription], list(subscriptions_for_bug))
+ # The subscription is not found when looking for COMMENTS or above.
+ subscriptions_for_bug = self.target.getSubscriptionsForBug(
+ bugtask.bug, BugNotificationLevel.COMMENTS)
+ self.assertEqual([], list(subscriptions_for_bug))
+
def test_getSubscriptionsForBug_with_multiple_filters(self):
# If multiple filters exist for a subscription, all filters must
# match.
Follow ups