Esempio n. 1
0
 def test_duplicate_edit_notifications(self):
     # Bug edits for a duplicate are sent to duplicate subscribers only.
     with notify_modified(self.dupe_bug, ['description'],
                          user=self.dupe_bug.owner):
         self.dupe_bug.description = 'A changed description'
     latest_notification = BugNotification.selectFirst(orderBy='-id')
     recipients = set(recipient.person
                      for recipient in latest_notification.recipients)
     self.assertEqual(self.dupe_subscribers, recipients)
 def test_comment_notifications(self):
     # New comments are only sent to subscribers of the duplicate
     # bug, not to subscribers of the master bug.
     self.dupe_bug.newMessage(self.dupe_bug.owner,
                              subject='subject',
                              content='content')
     latest_notification = BugNotification.selectFirst(orderBy='-id')
     recipients = set(recipient.person
                      for recipient in latest_notification.recipients)
     self.assertEqual(self.dupe_subscribers, recipients)
 def test_comment_notifications(self):
     # New comments are only sent to subscribers of the duplicate
     # bug, not to subscribers of the master bug.
     self.dupe_bug.newMessage(
         self.dupe_bug.owner, subject='subject', content='content')
     latest_notification = BugNotification.selectFirst(orderBy='-id')
     recipients = set(
         recipient.person
         for recipient in latest_notification.recipients)
     self.assertEqual(self.dupe_subscribers, recipients)
 def test_for_bug_modifier_header(self):
     """Test X-Launchpad-Bug-Modifier appears when a bug is modified."""
     self.bug_task.transitionToStatus(BugTaskStatus.CONFIRMED, self.user)
     notify(ObjectModifiedEvent(self.bug_task, self.bug_task_before_modification, ["status"], user=self.user))
     transaction.commit()
     latest_notification = BugNotification.selectFirst(orderBy="-id")
     notifications, omitted, messages = construct_email_notifications([latest_notification])
     self.assertEqual(len(notifications), 1, "email notification not created")
     headers = [msg["X-Launchpad-Bug-Modifier"] for msg in messages]
     self.assertEqual(len(headers), len(messages))
 def test_for_bug_modifier_header(self):
     """Test X-Launchpad-Bug-Modifier appears when a bugtask is deleted."""
     self.bug_task.delete(self.user)
     transaction.commit()
     latest_notification = BugNotification.selectFirst(orderBy='-id')
     notifications, omitted, messages = construct_email_notifications(
         [latest_notification])
     self.assertEqual(len(notifications), 1,
                      'email notification not created')
     headers = [msg['X-Launchpad-Bug-Modifier'] for msg in messages]
     self.assertEqual(len(headers), len(messages))
Esempio n. 6
0
 def test_assignee_new_subscriber(self):
     """Build a list of people who will receive emails about the bug
     task changes and ensure the assignee is not one."""
     with notify_modified(self.bug_task, ['assignee'], user=self.user):
         self.bug_task.transitionToAssignee(self.person_assigned)
     latest_notification = BugNotification.selectFirst(orderBy='-id')
     notifications, omitted, messages = construct_email_notifications(
         [latest_notification])
     self.assertEqual(len(notifications), 1, 'email notication not created')
     receivers = [message['To'] for message in messages]
     self.assertFalse(self.person_assigned_email in receivers,
                      'Assignee was emailed about the bug task change')
 def test_branch_linked_notification(self):
     # Notices for branches linked to a duplicate are sent only
     # to subscribers of the duplicate.
     #
     # No one should really do this, but this case covers notices
     # provided by the Bug.addChange mechanism.
     branch = self.factory.makeBranch(owner=self.dupe_bug.owner)
     self.dupe_bug.linkBranch(branch, self.dupe_bug.owner)
     latest_notification = BugNotification.selectFirst(orderBy='-id')
     recipients = set(recipient.person
                      for recipient in latest_notification.recipients)
     self.assertEqual(self.dupe_subscribers, recipients)
 def test_for_bug_modifier_header(self):
     """Test X-Launchpad-Bug-Modifier appears when a bug is modified."""
     with notify_modified(self.bug_task, ['status'], user=self.user):
         self.bug_task.transitionToStatus(BugTaskStatus.CONFIRMED,
                                          self.user)
     transaction.commit()
     latest_notification = BugNotification.selectFirst(orderBy='-id')
     notifications, omitted, messages = construct_email_notifications(
         [latest_notification])
     self.assertEqual(len(notifications), 1,
                      'email notification not created')
     headers = [msg['X-Launchpad-Bug-Modifier'] for msg in messages]
     self.assertEqual(len(headers), len(messages))
 def test_branch_linked_notification(self):
     # Notices for branches linked to a duplicate are sent only
     # to subscribers of the duplicate.
     #
     # No one should really do this, but this case covers notices
     # provided by the Bug.addChange mechanism.
     branch = self.factory.makeBranch(owner=self.dupe_bug.owner)
     self.dupe_bug.linkBranch(branch, self.dupe_bug.owner)
     latest_notification = BugNotification.selectFirst(orderBy='-id')
     recipients = set(
         recipient.person
         for recipient in latest_notification.recipients)
     self.assertEqual(self.dupe_subscribers, recipients)
 def test_duplicate_edit_notifications(self):
     # Bug edits for a duplicate are sent to duplicate subscribers only.
     bug_before_modification = Snapshot(
         self.dupe_bug, providing=providedBy(self.dupe_bug))
     self.dupe_bug.description = 'A changed description'
     notify(ObjectModifiedEvent(
         self.dupe_bug, bug_before_modification, ['description'],
         user=self.dupe_bug.owner))
     latest_notification = BugNotification.selectFirst(orderBy='-id')
     recipients = set(
         recipient.person
         for recipient in latest_notification.recipients)
     self.assertEqual(self.dupe_subscribers, recipients)
 def test_duplicate_edit_notifications(self):
     # Bug edits for a duplicate are sent to duplicate subscribers only.
     bug_before_modification = Snapshot(self.dupe_bug,
                                        providing=providedBy(self.dupe_bug))
     self.dupe_bug.description = 'A changed description'
     notify(
         ObjectModifiedEvent(self.dupe_bug,
                             bug_before_modification, ['description'],
                             user=self.dupe_bug.owner))
     latest_notification = BugNotification.selectFirst(orderBy='-id')
     recipients = set(recipient.person
                      for recipient in latest_notification.recipients)
     self.assertEqual(self.dupe_subscribers, recipients)
 def test_dup_subscriber_change_notification_message(self):
     """Duplicate bug number in the reason (email footer) for
        duplicate subscribers when a master bug is modified."""
     with notify_modified(self.master_bug_task, ['status'], user=self.user):
         self.master_bug_task.transitionToStatus(
             BugTaskStatus.CONFIRMED, self.user)
     transaction.commit()
     latest_notification = BugNotification.selectFirst(orderBy='-id')
     notifications, omitted, messages = construct_email_notifications(
         [latest_notification])
     self.assertEqual(
         len(notifications), 1, 'email notification not created')
     rationale = 'duplicate bug report (%i)' % self.dup_bug.id
     self.assertIn(rationale, str(messages[-1]))
Esempio n. 13
0
 def test_team_assigned_new_subscriber(self):
     """Assign a team, who is not subscribed to a bug, a bug task and
     ensure that team members do not receive an email about the bug
     task changes."""
     with notify_modified(self.bug_task, ['assignee'], user=self.user):
         self.bug_task.transitionToAssignee(self.team_assigned)
     latest_notification = BugNotification.selectFirst(orderBy='-id')
     notifications, omitted, messages = construct_email_notifications(
         [latest_notification])
     self.assertEqual(len(notifications), 1,
                      'email notification not created')
     receivers = [message['To'] for message in messages]
     self.assertFalse(self.team_member_email in receivers,
                      'Team member was emailed about the bug task change')
 def test_assignee_new_subscriber(self):
     """Build a list of people who will receive e-mails about the bug
     task changes and ensure the assignee is not one."""
     self.bug_task.transitionToAssignee(self.person_assigned)
     notify(ObjectModifiedEvent(
         self.bug_task, self.bug_task_before_modification,
         ['assignee'], user=self.user))
     latest_notification = BugNotification.selectFirst(orderBy='-id')
     notifications, omitted, messages = construct_email_notifications(
         [latest_notification])
     self.assertEqual(len(notifications), 1,
                      'email notication not created')
     receivers = [message['To'] for message in messages]
     self.assertFalse(self.person_assigned_email in receivers,
         'Assignee was emailed about the bug task change')
 def test_team_assigned_new_subscriber(self):
     """Assign a team, who is not subscribed to a bug, a bug task and
     ensure that team members do not receive an e-mail about the bug
     task changes."""
     self.bug_task.transitionToAssignee(self.team_assigned)
     notify(ObjectModifiedEvent(
         self.bug_task, self.bug_task_before_modification,
         ['assignee'], user=self.user))
     latest_notification = BugNotification.selectFirst(orderBy='-id')
     notifications, omitted, messages = construct_email_notifications(
         [latest_notification])
     self.assertEqual(len(notifications), 1,
                      'email notification not created')
     receivers = [message['To'] for message in messages]
     self.assertFalse(self.team_member_email in receivers,
         'Team member was emailed about the bug task change')
Esempio n. 16
0
 def getLatestBugNotification():
     return BugNotification.selectFirst(orderBy='-id')
Esempio n. 17
0
 def getLatestBugNotification():
     return BugNotification.selectFirst(orderBy='-id')