Merge lp:~danilo/launchpad/bug-718809 into lp:launchpad

Proposed by Данило Шеган
Status: Merged
Approved by: Данило Шеган
Approved revision: no longer in the source branch.
Merged at revision: 12399
Proposed branch: lp:~danilo/launchpad/bug-718809
Merge into: lp:launchpad
Diff against target: 166 lines (+35/-19)
8 files modified
lib/lp/bugs/doc/bugnotification-sending.txt (+14/-9)
lib/lp/bugs/scripts/tests/test_bugnotification.py (+0/-4)
lib/lp/bugs/tests/test_bugchanges.py (+3/-1)
lib/lp/registry/interfaces/person.py (+1/-1)
lib/lp/registry/model/person.py (+1/-1)
lib/lp/registry/stories/person/xx-person-edit.txt (+2/-2)
lib/lp/registry/tests/test_person.py (+6/-0)
lib/lp/testing/factory.py (+8/-1)
To merge this branch: bzr merge lp:~danilo/launchpad/bug-718809
Reviewer Review Type Date Requested Status
Aaron Bentley (community) Approve
Review via email: mp+49950@code.launchpad.net

Commit message

[r=abentley][bug=718809] For new users, default to not receiving self-generated bug mail.

Description of the change

= Bug 718809 =

Default to not receiving self-generated bug mail for new users.

== Proposed fix ==

Change interface and model column definitions, which basically changes the default. A separate branch (lp:~danilo/launchpad/db-bug-718809) will change the DB default, but that's mostly to avoid any confusion.

== Implementation details ==

I am sure many other tests which create Persons inline will start failing now, so I'll have to go and fix those as well. I am hoping the simple change to a call to makePerson will be sufficient.

Lint warning is because of a comment preceding class definition, number of blank lines is correct.

== Tests ==

bin/test -cvvt bugnotification-sending -t selfgenerated_bugnotifications

== Demo and Q/A ==

Register a new account and make sure the checkbox for "Send me bug notifications for changes I make" on https://qastaging.launchpad.net/people/+me/+edit is not checked.

= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/bugs/doc/bugnotification-sending.txt
  lib/lp/testing/factory.py
  lib/lp/registry/interfaces/person.py
  lib/lp/registry/model/person.py
  lib/lp/registry/tests/test_person.py

./lib/lp/registry/interfaces/person.py
     604: E302 expected 2 blank lines, found 1

To post a comment you must log in.
Revision history for this message
Данило Шеган (danilo) wrote :

FWIW, no more test failures in lp.bugs module.

Revision history for this message
Aaron Bentley (abentley) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/bugs/doc/bugnotification-sending.txt'
2--- lib/lp/bugs/doc/bugnotification-sending.txt 2011-02-16 14:11:46 +0000
3+++ lib/lp/bugs/doc/bugnotification-sending.txt 2011-02-17 09:20:33 +0000
4@@ -875,7 +875,8 @@
5 ... "will be automatically wrapped by the BugNotification "
6 ... "machinery. Ain't technology great?")
7 ... verbose_person = factory.makePerson(
8- ... displayname='Verbose Person', email='verbose@example.com')
9+ ... displayname='Verbose Person', email='verbose@example.com',
10+ ... selfgenerated_bugnotifications=True)
11 ... verbose_person.verbose_bugnotifications = True
12 ... ignored = bug.subscribe(verbose_person, verbose_person)
13 ... concise_person = factory.makePerson(
14@@ -1098,17 +1099,21 @@
15 they generated. For now, everyone receives these notifications whether they
16 want them or not.
17
18- >>> verbose_person.selfgenerated_bugnotifications
19- True
20- >>> with lp_dbuser():
21- ... verbose_person.selfgenerated_bugnotifications = False
22+ >>> with lp_dbuser():
23+ ... person = factory.makePerson()
24+ >>> person.selfgenerated_bugnotifications
25+ False
26+ >>> with lp_dbuser():
27+ ... person.selfgenerated_bugnotifications = True
28
29 Teams provide this attribute read-only.
30
31- >>> verbose_team.selfgenerated_bugnotifications
32- True
33- >>> with lp_dbuser():
34- ... verbose_team.selfgenerated_bugnotifications = False
35+ >>> with lp_dbuser():
36+ ... team = factory.makeTeam()
37+ >>> team.selfgenerated_bugnotifications
38+ False
39+ >>> with lp_dbuser():
40+ ... team.selfgenerated_bugnotifications = True
41 Traceback (most recent call last):
42 ...
43 NotImplementedError: Teams do not support changing this attribute.
44
45=== modified file 'lib/lp/bugs/scripts/tests/test_bugnotification.py'
46--- lib/lp/bugs/scripts/tests/test_bugnotification.py 2010-10-06 18:53:53 +0000
47+++ lib/lp/bugs/scripts/tests/test_bugnotification.py 2011-02-17 09:20:33 +0000
48@@ -456,7 +456,3 @@
49 expected = [notifications[0:3], notifications[3:4]]
50 observed = list(notification_batches(notifications))
51 self.assertEquals(expected, observed)
52-
53-
54-def test_suite():
55- return unittest.TestLoader().loadTestsFromName(__name__)
56
57=== modified file 'lib/lp/bugs/tests/test_bugchanges.py'
58--- lib/lp/bugs/tests/test_bugchanges.py 2011-02-09 21:51:29 +0000
59+++ lib/lp/bugs/tests/test_bugchanges.py 2011-02-17 09:20:33 +0000
60@@ -38,7 +38,9 @@
61 def setUp(self):
62 super(TestBugChanges, self).setUp('foo.bar@canonical.com')
63 self.admin_user = getUtility(ILaunchBag).user
64- self.user = self.factory.makePerson(displayname='Arthur Dent')
65+ self.user = self.factory.makePerson(
66+ displayname='Arthur Dent',
67+ selfgenerated_bugnotifications=True)
68 self.product = self.factory.makeProduct(
69 owner=self.user, official_malone=True)
70 self.bug = self.factory.makeBug(product=self.product, owner=self.user)
71
72=== modified file 'lib/lp/registry/interfaces/person.py'
73--- lib/lp/registry/interfaces/person.py 2011-02-07 16:46:35 +0000
74+++ lib/lp/registry/interfaces/person.py 2011-02-17 09:20:33 +0000
75@@ -633,7 +633,7 @@
76
77 selfgenerated_bugnotifications = Bool(
78 title=_("Send me bug notifications for changes I make."),
79- required=False, default=True)
80+ required=False, default=False)
81
82
83 class IPersonPublic(IHasBranches, IHasSpecifications,
84
85=== modified file 'lib/lp/registry/model/person.py'
86--- lib/lp/registry/model/person.py 2011-02-13 15:40:24 +0000
87+++ lib/lp/registry/model/person.py 2011-02-17 09:20:33 +0000
88@@ -371,7 +371,7 @@
89 personID = Int("person", default=None, primary=True)
90 person = Reference(personID, "Person.id")
91
92- selfgenerated_bugnotifications = BoolCol(notNull=True, default=True)
93+ selfgenerated_bugnotifications = BoolCol(notNull=True, default=False)
94
95
96 def readonly_settings(message, interface):
97
98=== modified file 'lib/lp/registry/stories/person/xx-person-edit.txt'
99--- lib/lp/registry/stories/person/xx-person-edit.txt 2011-02-07 21:29:06 +0000
100+++ lib/lp/registry/stories/person/xx-person-edit.txt 2011-02-17 09:20:33 +0000
101@@ -69,7 +69,7 @@
102 >>> self_generated_control = browser.getControl(
103 ... "Send me bug notifications for changes I make.")
104 >>> self_generated_control.selected
105- True
106+ False
107 >>> self_generated_control.click()
108
109 >>> browser.getControl('Save').click()
110@@ -85,4 +85,4 @@
111 False
112 >>> browser.getControl(
113 ... "Send me bug notifications for changes I make.").selected
114- False
115+ True
116
117=== modified file 'lib/lp/registry/tests/test_person.py'
118--- lib/lp/registry/tests/test_person.py 2011-02-03 08:38:27 +0000
119+++ lib/lp/registry/tests/test_person.py 2011-02-17 09:20:33 +0000
120@@ -278,6 +278,12 @@
121 user.getOwnedOrDrivenPillars()]
122 self.assertEqual(expected_pillars, received_pillars)
123
124+ def test_selfgenerated_bugnotifications_none_by_default(self):
125+ # Default for new accounts is to not get any
126+ # self-generated bug notifications by default.
127+ user = self.factory.makePerson()
128+ self.assertFalse(user.selfgenerated_bugnotifications)
129+
130
131 class TestPersonStates(TestCaseWithFactory):
132
133
134=== modified file 'lib/lp/testing/factory.py'
135--- lib/lp/testing/factory.py 2011-02-11 19:11:42 +0000
136+++ lib/lp/testing/factory.py 2011-02-17 09:20:33 +0000
137@@ -547,7 +547,8 @@
138 def makePerson(
139 self, email=None, name=None, password=None,
140 email_address_status=None, hide_email_addresses=False,
141- displayname=None, time_zone=None, latitude=None, longitude=None):
142+ displayname=None, time_zone=None, latitude=None, longitude=None,
143+ selfgenerated_bugnotifications=False):
144 """Create and return a new, arbitrary Person.
145
146 :param email: The email address for the new person.
147@@ -564,6 +565,7 @@
148 :param time_zone: This person's time zone, as a string.
149 :param latitude: This person's latitude, as a float.
150 :param longitude: This person's longitude, as a float.
151+ :param selfgenerated_bugnotifications: Receive own bugmail.
152 """
153 if email is None:
154 email = self.getUniqueEmailAddress()
155@@ -594,6 +596,11 @@
156 # Make sure the non-security-proxied object is not returned.
157 del naked_person
158
159+ if selfgenerated_bugnotifications:
160+ # Set it explicitely only when True because the default
161+ # is False.
162+ person.selfgenerated_bugnotifications = True
163+
164 # To make the person someone valid in Launchpad, validate the
165 # email.
166 if email_address_status == EmailAddressStatus.PREFERRED: