launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #00687
[Merge] lp:~allenap/launchpad/refactor-get-email-notifications-pt2 into lp:launchpad/devel
Gavin Panella has proposed merging lp:~allenap/launchpad/refactor-get-email-notifications-pt2 into lp:launchpad/devel with lp:~allenap/launchpad/refactor-mailnotification as a prerequisite.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
#621140 get_email_notifications() is confusing.
https://bugs.launchpad.net/bugs/621140
Remove unnecessary doctest of batching in get_email_notifications(); it's now unit tested in test_bugnotification.
--
https://code.launchpad.net/~allenap/launchpad/refactor-get-email-notifications-pt2/+merge/33233
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~allenap/launchpad/refactor-get-email-notifications-pt2 into lp:launchpad/devel.
=== modified file 'lib/lp/bugs/doc/bugnotification-sending.txt'
--- lib/lp/bugs/doc/bugnotification-sending.txt 2010-08-19 09:45:38 +0000
+++ lib/lp/bugs/doc/bugnotification-sending.txt 2010-08-20 16:05:21 +0000
@@ -283,246 +283,6 @@
To: test@xxxxxxxxxxxxx
...
-If we insert yet another comment, it will be sent as a separate email.
-
- >>> new_comment = getUtility(IMessageSet).fromText(
- ... 'subject', 'another comment.', sample_person,
- ... datecreated=ten_minutes_ago)
- >>> bug_one.addCommentNotification(new_comment)
- >>> pending_notifications = getUtility(
- ... IBugNotificationSet).getNotificationsToSend()
- >>> len(pending_notifications)
- 6
-
- >>> email_notifications = get_email_notifications(pending_notifications)
- >>> for bug_notifications, messages in email_notifications:
- ... for message in messages:
- ... print_notification(message)
- To: foo.bar@xxxxxxxxxxxxx
- ...
- To: mark@xxxxxxxxxxx
- ...
- To: support@xxxxxxxxxx
- From: Sample Person <1@xxxxxxxxxxxxxxxxxx>
- Subject: [Bug 1] Re: Firefox does not support SVG
- X-Launchpad-Message-Rationale: Registrant (Ubuntu) @ubuntu-team
- <BLANKLINE>
- a new comment.
- <BLANKLINE>
- ** Summary changed to: New summary.
- <BLANKLINE>
- ** Visibility changed to: Private.
- <BLANKLINE>
- ** Summary changed to: Another summary.
- <BLANKLINE>
- ** Visibility changed to: Public.
- <BLANKLINE>
- --
- Firefox does not support SVG
- http://bugs.launchpad.dev/bugs/1
- You received this bug notification because you are a member of Ubuntu
- Team, which is the registrant for Ubuntu.
- <BLANKLINE>
- ----------------------------------------------------------------------
- To: test@xxxxxxxxxxxxx
- ...
- To: foo.bar@xxxxxxxxxxxxx
- ...
- To: mark@xxxxxxxxxxx
- ...
- To: support@xxxxxxxxxx
- From: Sample Person <1@xxxxxxxxxxxxxxxxxx>
- Subject: [Bug 1] subject
- X-Launchpad-Message-Rationale: Registrant (Ubuntu) @ubuntu-team
- <BLANKLINE>
- another comment.
- <BLANKLINE>
- --
- Firefox does not support SVG
- http://bugs.launchpad.dev/bugs/1
- You received this bug notification because you are a member of Ubuntu
- Team, which is the registrant for Ubuntu.
- <BLANKLINE>
- ----------------------------------------------------------------------
- To: test@xxxxxxxxxxxxx
- ...
-
- >>> flush_notifications()
-
-If we add three comments, three notifications will be sent:
-
- >>> new_comment = getUtility(IMessageSet).fromText(
- ... 'subject', 'a comment.', sample_person,
- ... datecreated=ten_minutes_ago)
- >>> bug_one.addCommentNotification(new_comment)
- >>> new_comment = getUtility(IMessageSet).fromText(
- ... 'subject', 'another comment.', sample_person,
- ... datecreated=ten_minutes_ago)
- >>> bug_one.addCommentNotification(new_comment)
- >>> new_comment = getUtility(IMessageSet).fromText(
- ... 'subject', 'yet another comment.', sample_person,
- ... datecreated=ten_minutes_ago)
- >>> bug_one.addCommentNotification(new_comment)
- >>> pending_notifications = getUtility(
- ... IBugNotificationSet).getNotificationsToSend()
- >>> len(pending_notifications)
- 3
-
- >>> email_notifications = get_email_notifications(pending_notifications)
- >>> for bug_notifications, messages in email_notifications:
- ... for message in messages:
- ... print_notification(message)
- To: foo.bar@xxxxxxxxxxxxx
- ...
- To: mark@xxxxxxxxxxx
- ...
- To: support@xxxxxxxxxx
- From: Sample Person <1@xxxxxxxxxxxxxxxxxx>
- Subject: [Bug 1] subject
- X-Launchpad-Message-Rationale: Registrant (Ubuntu) @ubuntu-team
- <BLANKLINE>
- a comment.
- <BLANKLINE>
- --
- Firefox does not support SVG
- http://bugs.launchpad.dev/bugs/1
- You received this bug notification because you are a member of Ubuntu
- Team, which is the registrant for Ubuntu.
- <BLANKLINE>
- ----------------------------------------------------------------------
- To: test@xxxxxxxxxxxxx
- ...
- To: foo.bar@xxxxxxxxxxxxx
- ...
- To: mark@xxxxxxxxxxx
- ...
- To: support@xxxxxxxxxx
- From: Sample Person <1@xxxxxxxxxxxxxxxxxx>
- Subject: [Bug 1] subject
- X-Launchpad-Message-Rationale: Registrant (Ubuntu) @ubuntu-team
- <BLANKLINE>
- another comment.
- <BLANKLINE>
- --
- Firefox does not support SVG
- http://bugs.launchpad.dev/bugs/1
- You received this bug notification because you are a member of Ubuntu
- Team, which is the registrant for Ubuntu.
- <BLANKLINE>
- ----------------------------------------------------------------------
- To: test@xxxxxxxxxxxxx
- ...
- To: foo.bar@xxxxxxxxxxxxx
- ...
- To: mark@xxxxxxxxxxx
- ...
- To: support@xxxxxxxxxx
- From: Sample Person <1@xxxxxxxxxxxxxxxxxx>
- Subject: [Bug 1] subject
- X-Launchpad-Message-Rationale: Registrant (Ubuntu) @ubuntu-team
- <BLANKLINE>
- yet another comment.
- <BLANKLINE>
- --
- Firefox does not support SVG
- http://bugs.launchpad.dev/bugs/1
- You received this bug notification because you are a member of Ubuntu
- Team, which is the registrant for Ubuntu.
- <BLANKLINE>
- ----------------------------------------------------------------------
- To: test@xxxxxxxxxxxxx
- ...
-
- >>> flush_notifications()
-
-If Sample Person does a few changes, and Foo Bar steps in and does a
-change in between, three notifications will be sent:
-
- >>> from canonical.launchpad.interfaces import IPersonSet
- >>> foo_bar = getUtility(IPersonSet).getByEmail('foo.bar@xxxxxxxxxxxxx')
- >>> comment = getUtility(IMessageSet).fromText(
- ... 'subject', 'a comment.', sample_person,
- ... datecreated=ten_minutes_ago)
- >>> bug_one.addCommentNotification(comment)
- >>> bug_one.addChangeNotification(
- ... '** Summary changed to: New summary.', foo_bar,
- ... when=ten_minutes_ago)
- >>> bug_one.addChangeNotification(
- ... '** Visibility changed to: Private.', sample_person,
- ... when=ten_minutes_ago)
-
- >>> pending_notifications = getUtility(
- ... IBugNotificationSet).getNotificationsToSend()
- >>> len(pending_notifications)
- 3
-
- >>> email_notifications = get_email_notifications(pending_notifications)
- >>> for bug_notifications, messages in email_notifications:
- ... for message in messages:
- ... print_notification(message)
- To: foo.bar@xxxxxxxxxxxxx
- ...
- To: mark@xxxxxxxxxxx
- ...
- To: support@xxxxxxxxxx
- From: Sample Person <1@xxxxxxxxxxxxxxxxxx>
- Subject: [Bug 1] subject
- X-Launchpad-Message-Rationale: Registrant (Ubuntu) @ubuntu-team
- <BLANKLINE>
- a comment.
- <BLANKLINE>
- --
- Firefox does not support SVG
- http://bugs.launchpad.dev/bugs/1
- You received this bug notification because you are a member of Ubuntu
- Team, which is the registrant for Ubuntu.
- <BLANKLINE>
- ----------------------------------------------------------------------
- To: test@xxxxxxxxxxxxx
- ...
- To: foo.bar@xxxxxxxxxxxxx
- ...
- To: mark@xxxxxxxxxxx
- ...
- To: support@xxxxxxxxxx
- From: Foo Bar <foo.bar@xxxxxxxxxxxxx>
- Subject: [Bug 1] Re: Firefox does not support SVG
- X-Launchpad-Message-Rationale: Registrant (Ubuntu) @ubuntu-team
- <BLANKLINE>
- ** Summary changed to: New summary.
- <BLANKLINE>
- --
- Firefox does not support SVG
- http://bugs.launchpad.dev/bugs/1
- You received this bug notification because you are a member of Ubuntu
- Team, which is the registrant for Ubuntu.
- <BLANKLINE>
- ----------------------------------------------------------------------
- To: test@xxxxxxxxxxxxx
- ...
- To: foo.bar@xxxxxxxxxxxxx
- ...
- To: mark@xxxxxxxxxxx
- ...
- To: support@xxxxxxxxxx
- From: Sample Person <1@xxxxxxxxxxxxxxxxxx>
- Subject: [Bug 1] Re: Firefox does not support SVG
- X-Launchpad-Message-Rationale: Registrant (Ubuntu) @ubuntu-team
- <BLANKLINE>
- ** Visibility changed to: Private.
- <BLANKLINE>
- --
- Firefox does not support SVG
- http://bugs.launchpad.dev/bugs/1
- You received this bug notification because you are a member of Ubuntu
- Team, which is the registrant for Ubuntu.
- <BLANKLINE>
- ----------------------------------------------------------------------
- To: test@xxxxxxxxxxxxx
- ...
-
- >>> flush_notifications()
-
We send the notification only if the user hasn't done any other changes
for the last 5 minutes:
@@ -538,153 +298,11 @@
>>> flush_notifications()
-A more complicated example, Sample Person does a change every minute,
-but Foo Bar does a change in between:
-
- >>> now = datetime.now(pytz.timezone('UTC'))
- >>> for minutes_ago in reversed(range(10)):
- ... if minutes_ago == 6:
- ... bug_one.addChangeNotification(
- ... '** Visibility changed to: Public.', foo_bar,
- ... when=now - timedelta(minutes=minutes_ago))
- ... bug_one.addChangeNotification(
- ... '** Visibility changed to: Private.', sample_person,
- ... when=now - timedelta(minutes=minutes_ago))
- >>> pending_notifications = getUtility(
- ... IBugNotificationSet).getNotificationsToSend()
- >>> len(pending_notifications)
- 4
- >>> for notification in pending_notifications:
- ... print notification.id, notification.message.owner.displayname
- 25 Sample Person
- 26 Sample Person
- 27 Sample Person
- 28 Foo Bar
-
- >>> flush_notifications()
-
-Let's take a more complete example, where we edit different bugs as
-well:
-
- >>> bug_two = getUtility(IBugSet).get(2)
- >>> long_comment = getUtility(IMessageSet).fromText(
- ... 'subject',
- ... 'This is a long comment, which is longer than 72 characters.'
- ... ' This should result in the lined being wrapped, so that it'
- ... " won't be displayed as a single long line. Let's add another"
- ... ' sentence just to make it longer.'
- ... '\r\n\r\n'
- ... "Let's add another paragraph to the comment as well, separating"
- ... " it with dos-style line endings.",
- ... foo_bar, datecreated=now - timedelta(minutes=6))
- >>> for minutes_ago in reversed(range(10)):
- ... if minutes_ago == 6:
- ... bug_one.addChangeNotification(
- ... '** Visibility changed to: Public.', foo_bar,
- ... when=now - timedelta(minutes=minutes_ago))
- ... bug_one.addCommentNotification(long_comment)
- ... bug_two.addChangeNotification(
- ... '** Visibility changed to: Public.', foo_bar,
- ... when=now - timedelta(minutes=minutes_ago))
- ... bug_one.addChangeNotification(
- ... '** Visibility changed to: Private.', sample_person,
- ... when=now - timedelta(minutes=minutes_ago))
- ... bug_two.addChangeNotification(
- ... '** Visibility changed to: Private.', sample_person,
- ... when=now - timedelta(minutes=minutes_ago))
- >>> pending_notifications = getUtility(
- ... IBugNotificationSet).getNotificationsToSend()
- >>> len(pending_notifications)
- 9
-
- >>> email_notifications = get_email_notifications(pending_notifications)
- >>> for bug_notifications, messages in email_notifications:
- ... for message in messages:
- ... print_notification_headers(message)
- ... print
- To: mark@xxxxxxxxxxx
- From: Sample Person <2@xxxxxxxxxxxxxxxxxx>
- Subject: [Bug 2] Re: Blackhole Trash folder
- X-Launchpad-Message-Rationale: Registrant (Debian)
- <BLANKLINE>
- To: support@xxxxxxxxxx
- From: Sample Person <2@xxxxxxxxxxxxxxxxxx>
- Subject: [Bug 2] Re: Blackhole Trash folder
- X-Launchpad-Message-Rationale: Registrant (Tomcat) @ubuntu-team
- <BLANKLINE>
- To: test@xxxxxxxxxxxxx
- From: Sample Person <2@xxxxxxxxxxxxxxxxxx>
- Subject: [Bug 2] Re: Blackhole Trash folder
- X-Launchpad-Message-Rationale: Assignee
- <BLANKLINE>
- To: mark@xxxxxxxxxxx
- From: Foo Bar <foo.bar@xxxxxxxxxxxxx>
- Subject: [Bug 2] Re: Blackhole Trash folder
- X-Launchpad-Message-Rationale: Registrant (Debian)
- <BLANKLINE>
- To: support@xxxxxxxxxx
- From: Foo Bar <foo.bar@xxxxxxxxxxxxx>
- Subject: [Bug 2] Re: Blackhole Trash folder
- X-Launchpad-Message-Rationale: Registrant (Tomcat) @ubuntu-team
- <BLANKLINE>
- To: test@xxxxxxxxxxxxx
- From: Foo Bar <foo.bar@xxxxxxxxxxxxx>
- Subject: [Bug 2] Re: Blackhole Trash folder
- X-Launchpad-Message-Rationale: Assignee
- <BLANKLINE>
- To: foo.bar@xxxxxxxxxxxxx
- From: Sample Person <1@xxxxxxxxxxxxxxxxxx>
- Subject: [Bug 1] Re: Firefox does not support SVG
- X-Launchpad-Message-Rationale: Subscriber (mozilla-firefox in ubuntu)
- <BLANKLINE>
- To: mark@xxxxxxxxxxx
- From: Sample Person <1@xxxxxxxxxxxxxxxxxx>
- Subject: [Bug 1] Re: Firefox does not support SVG
- X-Launchpad-Message-Rationale: Assignee
- <BLANKLINE>
- To: support@xxxxxxxxxx
- From: Sample Person <1@xxxxxxxxxxxxxxxxxx>
- Subject: [Bug 1] Re: Firefox does not support SVG
- X-Launchpad-Message-Rationale: Registrant (Ubuntu) @ubuntu-team
- <BLANKLINE>
- To: test@xxxxxxxxxxxxx
- From: Sample Person <1@xxxxxxxxxxxxxxxxxx>
- Subject: [Bug 1] Re: Firefox does not support SVG
- X-Launchpad-Message-Rationale: Subscriber
- <BLANKLINE>
- To: foo.bar@xxxxxxxxxxxxx
- From: Foo Bar <foo.bar@xxxxxxxxxxxxx>
- Subject: [Bug 1] Re: Firefox does not support SVG
- X-Launchpad-Message-Rationale: Subscriber (mozilla-firefox in ubuntu)
- <BLANKLINE>
- To: mark@xxxxxxxxxxx
- From: Foo Bar <foo.bar@xxxxxxxxxxxxx>
- Subject: [Bug 1] Re: Firefox does not support SVG
- X-Launchpad-Message-Rationale: Assignee
- <BLANKLINE>
- To: support@xxxxxxxxxx
- From: Foo Bar <foo.bar@xxxxxxxxxxxxx>
- Subject: [Bug 1] Re: Firefox does not support SVG
- X-Launchpad-Message-Rationale: Registrant (Ubuntu) @ubuntu-team
- <BLANKLINE>
- To: test@xxxxxxxxxxxxx
- From: Foo Bar <foo.bar@xxxxxxxxxxxxx>
- Subject: [Bug 1] Re: Firefox does not support SVG
- X-Launchpad-Message-Rationale: Subscriber
- <BLANKLINE>
-
There's a blank line before the signature, and the signature marker has
a trailing space.
>>> message.get_payload(decode=True).splitlines()
- ['This is a long comment, which is longer than 72 characters. This should',
- "result in the lined being wrapped, so that it won't be displayed as a",
- "single long line. Let's add another sentence just to make it longer.",
- '',
- "Let's add another paragraph to the comment as well, separating it with",
- 'dos-style line endings.',
- '',
- '** Visibility changed to: Public.',
+ [...,
'',
'-- ',
'Firefox does not support SVG',
@@ -697,6 +315,7 @@
If a team without a contact address is subscribed to the bug, the
notification will be sent to all members individually.
+ >>> from lp.registry.interfaces.person import IPersonSet
>>> shipit_admins = getUtility(IPersonSet).getByName('shipit-admins')
>>> shipit_admins.preferredemail is None
True
@@ -1167,6 +786,8 @@
... print message.get('X-Launchpad-Bug-Commenters')
name12
+ >>> foo_bar = getUtility(IPersonSet).getByEmail('foo.bar@xxxxxxxxxxxxx')
+
>>> from lp.bugs.interfaces.bugmessage import IBugMessageSet
>>> getUtility(IBugMessageSet).createMessage(
... 'Hungry', bug_three, foo_bar, "Make me a sandwich.")
@@ -1371,7 +992,7 @@
<BLANKLINE>
----------------------------------------------------------------------
-And Concise Team Person does too, even though his team doesn't want them:
+And Concise Team Person does too, even though his team doesn't want them:
>>> print_notification(collated_messages['conciseteam@xxxxxxxxxxx'][0])
To: conciseteam@xxxxxxxxxxx
@@ -1394,6 +1015,7 @@
<BLANKLINE>
----------------------------------------------------------------------
+
== Notification Recipients ==
Bug notifications are sent to direct subscribers of a bug as well as to