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
=== modified file 'lib/lp/bugs/doc/bugnotification-sending.txt'
--- lib/lp/bugs/doc/bugnotification-sending.txt 2011-02-16 14:11:46 +0000
+++ lib/lp/bugs/doc/bugnotification-sending.txt 2011-02-17 09:20:33 +0000
@@ -875,7 +875,8 @@
875 ... "will be automatically wrapped by the BugNotification "875 ... "will be automatically wrapped by the BugNotification "
876 ... "machinery. Ain't technology great?")876 ... "machinery. Ain't technology great?")
877 ... verbose_person = factory.makePerson(877 ... verbose_person = factory.makePerson(
878 ... displayname='Verbose Person', email='verbose@example.com')878 ... displayname='Verbose Person', email='verbose@example.com',
879 ... selfgenerated_bugnotifications=True)
879 ... verbose_person.verbose_bugnotifications = True880 ... verbose_person.verbose_bugnotifications = True
880 ... ignored = bug.subscribe(verbose_person, verbose_person)881 ... ignored = bug.subscribe(verbose_person, verbose_person)
881 ... concise_person = factory.makePerson(882 ... concise_person = factory.makePerson(
@@ -1098,17 +1099,21 @@
1098they generated. For now, everyone receives these notifications whether they1099they generated. For now, everyone receives these notifications whether they
1099want them or not.1100want them or not.
11001101
1101 >>> verbose_person.selfgenerated_bugnotifications1102 >>> with lp_dbuser():
1102 True1103 ... person = factory.makePerson()
1103 >>> with lp_dbuser():1104 >>> person.selfgenerated_bugnotifications
1104 ... verbose_person.selfgenerated_bugnotifications = False1105 False
1106 >>> with lp_dbuser():
1107 ... person.selfgenerated_bugnotifications = True
11051108
1106Teams provide this attribute read-only.1109Teams provide this attribute read-only.
11071110
1108 >>> verbose_team.selfgenerated_bugnotifications1111 >>> with lp_dbuser():
1109 True1112 ... team = factory.makeTeam()
1110 >>> with lp_dbuser():1113 >>> team.selfgenerated_bugnotifications
1111 ... verbose_team.selfgenerated_bugnotifications = False1114 False
1115 >>> with lp_dbuser():
1116 ... team.selfgenerated_bugnotifications = True
1112 Traceback (most recent call last):1117 Traceback (most recent call last):
1113 ...1118 ...
1114 NotImplementedError: Teams do not support changing this attribute.1119 NotImplementedError: Teams do not support changing this attribute.
11151120
=== modified file 'lib/lp/bugs/scripts/tests/test_bugnotification.py'
--- lib/lp/bugs/scripts/tests/test_bugnotification.py 2010-10-06 18:53:53 +0000
+++ lib/lp/bugs/scripts/tests/test_bugnotification.py 2011-02-17 09:20:33 +0000
@@ -456,7 +456,3 @@
456 expected = [notifications[0:3], notifications[3:4]]456 expected = [notifications[0:3], notifications[3:4]]
457 observed = list(notification_batches(notifications))457 observed = list(notification_batches(notifications))
458 self.assertEquals(expected, observed)458 self.assertEquals(expected, observed)
459
460
461def test_suite():
462 return unittest.TestLoader().loadTestsFromName(__name__)
463459
=== modified file 'lib/lp/bugs/tests/test_bugchanges.py'
--- lib/lp/bugs/tests/test_bugchanges.py 2011-02-09 21:51:29 +0000
+++ lib/lp/bugs/tests/test_bugchanges.py 2011-02-17 09:20:33 +0000
@@ -38,7 +38,9 @@
38 def setUp(self):38 def setUp(self):
39 super(TestBugChanges, self).setUp('foo.bar@canonical.com')39 super(TestBugChanges, self).setUp('foo.bar@canonical.com')
40 self.admin_user = getUtility(ILaunchBag).user40 self.admin_user = getUtility(ILaunchBag).user
41 self.user = self.factory.makePerson(displayname='Arthur Dent')41 self.user = self.factory.makePerson(
42 displayname='Arthur Dent',
43 selfgenerated_bugnotifications=True)
42 self.product = self.factory.makeProduct(44 self.product = self.factory.makeProduct(
43 owner=self.user, official_malone=True)45 owner=self.user, official_malone=True)
44 self.bug = self.factory.makeBug(product=self.product, owner=self.user)46 self.bug = self.factory.makeBug(product=self.product, owner=self.user)
4547
=== modified file 'lib/lp/registry/interfaces/person.py'
--- lib/lp/registry/interfaces/person.py 2011-02-07 16:46:35 +0000
+++ lib/lp/registry/interfaces/person.py 2011-02-17 09:20:33 +0000
@@ -633,7 +633,7 @@
633633
634 selfgenerated_bugnotifications = Bool(634 selfgenerated_bugnotifications = Bool(
635 title=_("Send me bug notifications for changes I make."),635 title=_("Send me bug notifications for changes I make."),
636 required=False, default=True)636 required=False, default=False)
637637
638638
639class IPersonPublic(IHasBranches, IHasSpecifications,639class IPersonPublic(IHasBranches, IHasSpecifications,
640640
=== modified file 'lib/lp/registry/model/person.py'
--- lib/lp/registry/model/person.py 2011-02-13 15:40:24 +0000
+++ lib/lp/registry/model/person.py 2011-02-17 09:20:33 +0000
@@ -371,7 +371,7 @@
371 personID = Int("person", default=None, primary=True)371 personID = Int("person", default=None, primary=True)
372 person = Reference(personID, "Person.id")372 person = Reference(personID, "Person.id")
373373
374 selfgenerated_bugnotifications = BoolCol(notNull=True, default=True)374 selfgenerated_bugnotifications = BoolCol(notNull=True, default=False)
375375
376376
377def readonly_settings(message, interface):377def readonly_settings(message, interface):
378378
=== modified file 'lib/lp/registry/stories/person/xx-person-edit.txt'
--- lib/lp/registry/stories/person/xx-person-edit.txt 2011-02-07 21:29:06 +0000
+++ lib/lp/registry/stories/person/xx-person-edit.txt 2011-02-17 09:20:33 +0000
@@ -69,7 +69,7 @@
69 >>> self_generated_control = browser.getControl(69 >>> self_generated_control = browser.getControl(
70 ... "Send me bug notifications for changes I make.")70 ... "Send me bug notifications for changes I make.")
71 >>> self_generated_control.selected71 >>> self_generated_control.selected
72 True72 False
73 >>> self_generated_control.click()73 >>> self_generated_control.click()
7474
75 >>> browser.getControl('Save').click()75 >>> browser.getControl('Save').click()
@@ -85,4 +85,4 @@
85 False85 False
86 >>> browser.getControl(86 >>> browser.getControl(
87 ... "Send me bug notifications for changes I make.").selected87 ... "Send me bug notifications for changes I make.").selected
88 False88 True
8989
=== modified file 'lib/lp/registry/tests/test_person.py'
--- lib/lp/registry/tests/test_person.py 2011-02-03 08:38:27 +0000
+++ lib/lp/registry/tests/test_person.py 2011-02-17 09:20:33 +0000
@@ -278,6 +278,12 @@
278 user.getOwnedOrDrivenPillars()]278 user.getOwnedOrDrivenPillars()]
279 self.assertEqual(expected_pillars, received_pillars)279 self.assertEqual(expected_pillars, received_pillars)
280280
281 def test_selfgenerated_bugnotifications_none_by_default(self):
282 # Default for new accounts is to not get any
283 # self-generated bug notifications by default.
284 user = self.factory.makePerson()
285 self.assertFalse(user.selfgenerated_bugnotifications)
286
281287
282class TestPersonStates(TestCaseWithFactory):288class TestPersonStates(TestCaseWithFactory):
283289
284290
=== modified file 'lib/lp/testing/factory.py'
--- lib/lp/testing/factory.py 2011-02-11 19:11:42 +0000
+++ lib/lp/testing/factory.py 2011-02-17 09:20:33 +0000
@@ -547,7 +547,8 @@
547 def makePerson(547 def makePerson(
548 self, email=None, name=None, password=None,548 self, email=None, name=None, password=None,
549 email_address_status=None, hide_email_addresses=False,549 email_address_status=None, hide_email_addresses=False,
550 displayname=None, time_zone=None, latitude=None, longitude=None):550 displayname=None, time_zone=None, latitude=None, longitude=None,
551 selfgenerated_bugnotifications=False):
551 """Create and return a new, arbitrary Person.552 """Create and return a new, arbitrary Person.
552553
553 :param email: The email address for the new person.554 :param email: The email address for the new person.
@@ -564,6 +565,7 @@
564 :param time_zone: This person's time zone, as a string.565 :param time_zone: This person's time zone, as a string.
565 :param latitude: This person's latitude, as a float.566 :param latitude: This person's latitude, as a float.
566 :param longitude: This person's longitude, as a float.567 :param longitude: This person's longitude, as a float.
568 :param selfgenerated_bugnotifications: Receive own bugmail.
567 """569 """
568 if email is None:570 if email is None:
569 email = self.getUniqueEmailAddress()571 email = self.getUniqueEmailAddress()
@@ -594,6 +596,11 @@
594 # Make sure the non-security-proxied object is not returned.596 # Make sure the non-security-proxied object is not returned.
595 del naked_person597 del naked_person
596598
599 if selfgenerated_bugnotifications:
600 # Set it explicitely only when True because the default
601 # is False.
602 person.selfgenerated_bugnotifications = True
603
597 # To make the person someone valid in Launchpad, validate the604 # To make the person someone valid in Launchpad, validate the
598 # email.605 # email.
599 if email_address_status == EmailAddressStatus.PREFERRED:606 if email_address_status == EmailAddressStatus.PREFERRED: