Merge lp:~danilo/launchpad/devel-bug-720826-clear-level-on-delete into lp:launchpad

Proposed by Данило Шеган
Status: Merged
Approved by: Данило Шеган
Approved revision: no longer in the source branch.
Merged at revision: 12504
Proposed branch: lp:~danilo/launchpad/devel-bug-720826-clear-level-on-delete
Merge into: lp:launchpad
Diff against target: 48 lines (+9/-1)
3 files modified
lib/lp/bugs/interfaces/bugsubscriptionfilter.py (+1/-1)
lib/lp/bugs/model/bugsubscriptionfilter.py (+4/-0)
lib/lp/bugs/model/tests/test_bugsubscriptionfilter.py (+4/-0)
To merge this branch: bzr merge lp:~danilo/launchpad/devel-bug-720826-clear-level-on-delete
Reviewer Review Type Date Requested Status
Leonard Richardson (community) Approve
Review via email: mp+51768@code.launchpad.net

Commit message

[r=leonardr][bug=720826][incr] Clear bug_notification_level on the "default" bug subscription filter when the final filter is removed.

Description of the change

= Unset bug notification level on final filter removal =

== Background ==

For every structural subscription, we have recently started enforcing that there is at least one BugSubscriptionFilter to match it. It is initially configured to not set any filtering.

As part of QA for
https://code.launchpad.net/~danilo/launchpad/auto-create-bugsubscriptionfilter/+merge/50371

I realized that when trying to remove final subscription filter, we do not unset the bug_notification_level to the default value.

This fixes that, and can be QAd in the same manner as the above MP.

== Tests ==

bin/test -cvvt test_delete_final

== Demo and Q/A ==

Add a structural subscription and go to https://bugs.qastaging.launchpad.net/people/+me/+structural-subscriptions and first set the notification level to non-default value (eg. lifecycle) and then try deleting it and see how it gets reset.

= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/bugs/model/bugsubscriptionfilter.py
  lib/lp/bugs/model/tests/test_bugsubscriptionfilter.py

To post a comment you must log in.
Revision history for this message
Leonard Richardson (leonardr) wrote :

This looks good.

Is there a better way to indicate that BugNotificationLevel.COMMENTS is the default value? That's the only problem I had reading this--it looked a little arbitrary.

review: Approve
Revision history for this message
Данило Шеган (danilo) wrote :

As discussed on IRC, yes there is. I am using that now.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/bugs/interfaces/bugsubscriptionfilter.py'
2--- lib/lp/bugs/interfaces/bugsubscriptionfilter.py 2011-02-01 04:57:42 +0000
3+++ lib/lp/bugs/interfaces/bugsubscriptionfilter.py 2011-03-01 16:52:25 +0000
4@@ -64,7 +64,7 @@
5 Choice(
6 title=_("Bug notification level"), required=True,
7 vocabulary=BugNotificationLevel,
8- default=BugNotificationLevel.NOTHING,
9+ default=BugNotificationLevel.COMMENTS,
10 description=_("The volume and type of bug notifications "
11 "this subscription will generate.")))
12
13
14=== modified file 'lib/lp/bugs/model/bugsubscriptionfilter.py'
15--- lib/lp/bugs/model/bugsubscriptionfilter.py 2011-02-18 17:37:10 +0000
16+++ lib/lp/bugs/model/bugsubscriptionfilter.py 2011-03-01 16:52:25 +0000
17@@ -202,5 +202,9 @@
18 def delete(self):
19 """See `IBugSubscriptionFilter`."""
20 self.importances = self.statuses = self.tags = ()
21+ # Revert bug notification level to the default.
22+ self.bug_notification_level = (
23+ IBugSubscriptionFilter.getDescriptionFor(
24+ 'bug_notification_level').default)
25 if self._has_other_filters():
26 Store.of(self).remove(self)
27
28=== modified file 'lib/lp/bugs/model/tests/test_bugsubscriptionfilter.py'
29--- lib/lp/bugs/model/tests/test_bugsubscriptionfilter.py 2011-02-18 17:37:10 +0000
30+++ lib/lp/bugs/model/tests/test_bugsubscriptionfilter.py 2011-03-01 16:52:25 +0000
31@@ -120,6 +120,8 @@
32 # Final remaining `BugSubscriptionFilter` can't be deleted.
33 # Only the linked data is removed.
34 bug_subscription_filter = self.subscription.bug_filters.one()
35+ bug_subscription_filter.bug_notification_level = (
36+ BugNotificationLevel.LIFECYCLE)
37 bug_subscription_filter.importances = [BugTaskImportance.LOW]
38 bug_subscription_filter.statuses = [BugTaskStatus.NEW]
39 bug_subscription_filter.tags = [u"foo"]
40@@ -129,6 +131,8 @@
41 bug_subscription_filter.delete()
42 IStore(bug_subscription_filter).flush()
43 self.assertIsNot(None, Store.of(bug_subscription_filter))
44+ self.assertEquals(BugNotificationLevel.COMMENTS,
45+ bug_subscription_filter.bug_notification_level)
46 self.assertContentEqual([], bug_subscription_filter.statuses)
47 self.assertContentEqual([], bug_subscription_filter.importances)
48 self.assertContentEqual([], bug_subscription_filter.tags)