launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #01431
[Merge] lp:~allenap/launchpad/subs-for-bugtask-bug-656194 into lp:launchpad
Gavin Panella has proposed merging lp:~allenap/launchpad/subs-for-bugtask-bug-656194 into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
#656194 getSubscriptionsForBug() would make more sense as getSubscriptionsForBugTask()
https://bugs.launchpad.net/bugs/656194
Switch getSusbcriptionsForBug() to *ForBugTask(). Not much else in it really.
--
https://code.launchpad.net/~allenap/launchpad/subs-for-bugtask-bug-656194/+merge/37835
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~allenap/launchpad/subs-for-bugtask-bug-656194 into lp:launchpad.
=== modified file 'lib/lp/registry/interfaces/structuralsubscription.py'
--- lib/lp/registry/interfaces/structuralsubscription.py 2010-10-05 09:23:22 +0000
+++ lib/lp/registry/interfaces/structuralsubscription.py 2010-10-07 10:11:44 +0000
@@ -200,8 +200,8 @@
def userHasBugSubscriptions(user):
"""Is `user` subscribed, directly or via a team, to bug mail?"""
- def getSubscriptionsForBug(bug, level):
- """Return subscriptions for a given `IBug` at `level`."""
+ def getSubscriptionsForBugTask(bug, level):
+ """Return subscriptions for a given `IBugTask` at `level`."""
class IStructuralSubscriptionTargetWrite(Interface):
=== modified file 'lib/lp/registry/model/structuralsubscription.py'
--- lib/lp/registry/model/structuralsubscription.py 2010-10-05 16:52:02 +0000
+++ lib/lp/registry/model/structuralsubscription.py 2010-10-07 10:11:44 +0000
@@ -484,21 +484,8 @@
return True
return False
- def getSubscriptionsForBug(self, bug, level):
+ def getSubscriptionsForBugTask(self, bugtask, level):
"""See `IStructuralSubscriptionTarget`."""
- if IProjectGroup.providedBy(self):
- targets = set(self.products)
- elif IMilestone.providedBy(self):
- targets = [self.series_target]
- else:
- targets = [self]
-
- bugtasks = [
- bugtask for bugtask in bug.bugtasks
- if bugtask.target in targets]
-
- assert len(bugtasks) != 0, repr(self)
-
origin = [
StructuralSubscription,
LeftJoin(
@@ -515,7 +502,7 @@
BugSubscriptionFilter.id)),
]
- if len(bug.tags) == 0:
+ if len(bugtask.bug.tags) == 0:
tag_conditions = [
BugSubscriptionFilter.include_any_tags == False,
]
@@ -534,13 +521,12 @@
# There's no status filter, or there is a status filter
# and and it matches.
Or(BugSubscriptionFilterStatus.id == None,
- BugSubscriptionFilterStatus.status.is_in(
- bugtask.status for bugtask in bugtasks)),
+ BugSubscriptionFilterStatus.status == bugtask.status),
# There's no importance filter, or there is an importance
# filter and it matches.
Or(BugSubscriptionFilterImportance.id == None,
- BugSubscriptionFilterImportance.importance.is_in(
- bugtask.importance for bugtask in bugtasks)),
+ BugSubscriptionFilterImportance.importance == (
+ bugtask.importance)),
# Any number of conditions relating to tags.
*tag_conditions)),
]
=== modified file 'lib/lp/registry/tests/test_structuralsubscriptiontarget.py'
--- lib/lp/registry/tests/test_structuralsubscriptiontarget.py 2010-10-06 18:53:53 +0000
+++ lib/lp/registry/tests/test_structuralsubscriptiontarget.py 2010-10-07 10:11:44 +0000
@@ -173,19 +173,20 @@
def makeBugTask(self):
return self.factory.makeBugTask(target=self.target)
- def test_getSubscriptionsForBug(self):
+ def test_getSubscriptionsForBugTask(self):
# If no one has a filtered subscription for the given bug, the result
- # of getSubscriptionsForBug() is the same as for getSubscriptions().
+ # of getSubscriptionsForBugTask() is the same as for
+ # getSubscriptions().
bugtask = self.makeBugTask()
subscriptions = self.target.getSubscriptions(
min_bug_notification_level=BugNotificationLevel.NOTHING)
- subscriptions_for_bug = self.target.getSubscriptionsForBug(
- bugtask.bug, BugNotificationLevel.NOTHING)
- self.assertEqual(list(subscriptions), list(subscriptions_for_bug))
+ subscriptions_for_bugtask = self.target.getSubscriptionsForBugTask(
+ bugtask, BugNotificationLevel.NOTHING)
+ self.assertEqual(list(subscriptions), list(subscriptions_for_bugtask))
- def test_getSubscriptionsForBug_with_filter_on_status(self):
+ def test_getSubscriptionsForBugTask_with_filter_on_status(self):
# If a status filter exists for a subscription, the result of
- # getSubscriptionsForBug() may be a subset of getSubscriptions().
+ # getSubscriptionsForBugTask() may be a subset of getSubscriptions().
bugtask = self.makeBugTask()
# Create a new subscription on self.target.
@@ -195,9 +196,9 @@
subscription.bug_notification_level = BugNotificationLevel.COMMENTS
# Without any filters the subscription is found.
- subscriptions_for_bug = self.target.getSubscriptionsForBug(
- bugtask.bug, BugNotificationLevel.NOTHING)
- self.assertEqual([subscription], list(subscriptions_for_bug))
+ subscriptions_for_bugtask = self.target.getSubscriptionsForBugTask(
+ bugtask, BugNotificationLevel.NOTHING)
+ self.assertEqual([subscription], list(subscriptions_for_bugtask))
# Filter the subscription to bugs in the CONFIRMED state.
subscription_filter = BugSubscriptionFilter()
@@ -205,19 +206,19 @@
subscription_filter.statuses = [BugTaskStatus.CONFIRMED]
# With the filter the subscription is not found.
- subscriptions_for_bug = self.target.getSubscriptionsForBug(
- bugtask.bug, BugNotificationLevel.NOTHING)
- self.assertEqual([], list(subscriptions_for_bug))
+ subscriptions_for_bugtask = self.target.getSubscriptionsForBugTask(
+ bugtask, BugNotificationLevel.NOTHING)
+ self.assertEqual([], list(subscriptions_for_bugtask))
# If the filter is adjusted, the subscription is found again.
subscription_filter.statuses = [bugtask.status]
- subscriptions_for_bug = self.target.getSubscriptionsForBug(
- bugtask.bug, BugNotificationLevel.NOTHING)
- self.assertEqual([subscription], list(subscriptions_for_bug))
+ subscriptions_for_bugtask = self.target.getSubscriptionsForBugTask(
+ bugtask, BugNotificationLevel.NOTHING)
+ self.assertEqual([subscription], list(subscriptions_for_bugtask))
- def test_getSubscriptionsForBug_with_filter_on_importance(self):
+ def test_getSubscriptionsForBugTask_with_filter_on_importance(self):
# If an importance filter exists for a subscription, the result of
- # getSubscriptionsForBug() may be a subset of getSubscriptions().
+ # getSubscriptionsForBugTask() may be a subset of getSubscriptions().
bugtask = self.makeBugTask()
# Create a new subscription on self.target.
@@ -227,9 +228,9 @@
subscription.bug_notification_level = BugNotificationLevel.COMMENTS
# Without any filters the subscription is found.
- subscriptions_for_bug = self.target.getSubscriptionsForBug(
- bugtask.bug, BugNotificationLevel.NOTHING)
- self.assertEqual([subscription], list(subscriptions_for_bug))
+ subscriptions_for_bugtask = self.target.getSubscriptionsForBugTask(
+ bugtask, BugNotificationLevel.NOTHING)
+ self.assertEqual([subscription], list(subscriptions_for_bugtask))
# Filter the subscription to bugs in the CRITICAL state.
subscription_filter = BugSubscriptionFilter()
@@ -237,19 +238,19 @@
subscription_filter.importances = [BugTaskImportance.CRITICAL]
# With the filter the subscription is not found.
- subscriptions_for_bug = self.target.getSubscriptionsForBug(
- bugtask.bug, BugNotificationLevel.NOTHING)
- self.assertEqual([], list(subscriptions_for_bug))
+ subscriptions_for_bugtask = self.target.getSubscriptionsForBugTask(
+ bugtask, BugNotificationLevel.NOTHING)
+ self.assertEqual([], list(subscriptions_for_bugtask))
# If the filter is adjusted, the subscription is found again.
subscription_filter.importances = [bugtask.importance]
- subscriptions_for_bug = self.target.getSubscriptionsForBug(
- bugtask.bug, BugNotificationLevel.NOTHING)
- self.assertEqual([subscription], list(subscriptions_for_bug))
+ subscriptions_for_bugtask = self.target.getSubscriptionsForBugTask(
+ bugtask, BugNotificationLevel.NOTHING)
+ self.assertEqual([subscription], list(subscriptions_for_bugtask))
- def test_getSubscriptionsForBug_with_filter_on_level(self):
+ def test_getSubscriptionsForBugTask_with_filter_on_level(self):
# All structural subscriptions have a level for bug notifications
- # which getSubscriptionsForBug() observes.
+ # which getSubscriptionsForBugTask() observes.
bugtask = self.makeBugTask()
# Create a new METADATA level subscription on self.target.
@@ -259,19 +260,19 @@
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))
+ subscriptions_for_bugtask = self.target.getSubscriptionsForBugTask(
+ bugtask, BugNotificationLevel.NOTHING)
+ self.assertEqual([subscription], list(subscriptions_for_bugtask))
# 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))
+ subscriptions_for_bugtask = self.target.getSubscriptionsForBugTask(
+ bugtask, BugNotificationLevel.METADATA)
+ self.assertEqual([subscription], list(subscriptions_for_bugtask))
# 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))
+ subscriptions_for_bugtask = self.target.getSubscriptionsForBugTask(
+ bugtask, BugNotificationLevel.COMMENTS)
+ self.assertEqual([], list(subscriptions_for_bugtask))
- def test_getSubscriptionsForBug_with_filter_include_any_tags(self):
+ def test_getSubscriptionsForBugTask_with_filter_include_any_tags(self):
# If a subscription filter has include_any_tags, a bug with one or
# more tags is matched.
bugtask = self.makeBugTask()
@@ -285,17 +286,17 @@
subscription_filter.include_any_tags = True
# Without any tags the subscription is not found.
- subscriptions_for_bug = self.target.getSubscriptionsForBug(
- bugtask.bug, BugNotificationLevel.NOTHING)
- self.assertEqual([], list(subscriptions_for_bug))
+ subscriptions_for_bugtask = self.target.getSubscriptionsForBugTask(
+ bugtask, BugNotificationLevel.NOTHING)
+ self.assertEqual([], list(subscriptions_for_bugtask))
# With any tag the subscription is found.
bugtask.bug.tags = ["foo"]
- subscriptions_for_bug = self.target.getSubscriptionsForBug(
- bugtask.bug, BugNotificationLevel.NOTHING)
- self.assertEqual([subscription], list(subscriptions_for_bug))
+ subscriptions_for_bugtask = self.target.getSubscriptionsForBugTask(
+ bugtask, BugNotificationLevel.NOTHING)
+ self.assertEqual([subscription], list(subscriptions_for_bugtask))
- def test_getSubscriptionsForBug_with_filter_exclude_any_tags(self):
+ def test_getSubscriptionsForBugTask_with_filter_exclude_any_tags(self):
# If a subscription filter has exclude_any_tags, only bugs with no
# tags are matched.
bugtask = self.makeBugTask()
@@ -309,17 +310,17 @@
subscription_filter.exclude_any_tags = True
# Without any tags the subscription is found.
- subscriptions_for_bug = self.target.getSubscriptionsForBug(
- bugtask.bug, BugNotificationLevel.NOTHING)
- self.assertEqual([subscription], list(subscriptions_for_bug))
+ subscriptions_for_bugtask = self.target.getSubscriptionsForBugTask(
+ bugtask, BugNotificationLevel.NOTHING)
+ self.assertEqual([subscription], list(subscriptions_for_bugtask))
# With any tag the subscription is not found.
bugtask.bug.tags = ["foo"]
- subscriptions_for_bug = self.target.getSubscriptionsForBug(
- bugtask.bug, BugNotificationLevel.NOTHING)
- self.assertEqual([], list(subscriptions_for_bug))
+ subscriptions_for_bugtask = self.target.getSubscriptionsForBugTask(
+ bugtask, BugNotificationLevel.NOTHING)
+ self.assertEqual([], list(subscriptions_for_bugtask))
- def test_getSubscriptionsForBug_with_multiple_filters(self):
+ def test_getSubscriptionsForBugTask_with_multiple_filters(self):
# If multiple filters exist for a subscription, all filters must
# match.
bugtask = self.makeBugTask()
@@ -337,23 +338,23 @@
subscription_filter.importances = [BugTaskImportance.CRITICAL]
# With the filter the subscription is not found.
- subscriptions_for_bug = self.target.getSubscriptionsForBug(
- bugtask.bug, BugNotificationLevel.NOTHING)
- self.assertEqual([], list(subscriptions_for_bug))
+ subscriptions_for_bugtask = self.target.getSubscriptionsForBugTask(
+ bugtask, BugNotificationLevel.NOTHING)
+ self.assertEqual([], list(subscriptions_for_bugtask))
# If the filter is adjusted to match status but not importance, the
# subscription is still not found.
subscription_filter.statuses = [bugtask.status]
- subscriptions_for_bug = self.target.getSubscriptionsForBug(
- bugtask.bug, BugNotificationLevel.NOTHING)
- self.assertEqual([], list(subscriptions_for_bug))
+ subscriptions_for_bugtask = self.target.getSubscriptionsForBugTask(
+ bugtask, BugNotificationLevel.NOTHING)
+ self.assertEqual([], list(subscriptions_for_bugtask))
# If the filter is adjusted to also match importance, the subscription
# is found again.
subscription_filter.importances = [bugtask.importance]
- subscriptions_for_bug = self.target.getSubscriptionsForBug(
- bugtask.bug, BugNotificationLevel.NOTHING)
- self.assertEqual([subscription], list(subscriptions_for_bug))
+ subscriptions_for_bugtask = self.target.getSubscriptionsForBugTask(
+ bugtask, BugNotificationLevel.NOTHING)
+ self.assertEqual([subscription], list(subscriptions_for_bugtask))
class TestStructuralSubscriptionForDistro(