def test_muted(self):
     self.addFilter(u"Test filter")
     BugSubscriptionFilterMute(
         person=self.subscription.subscriber,
         filter=self.notification.bug_filters.one())
     filtered, omitted, messages = construct_email_notifications(
         [self.notification])
     self.assertEqual(list(messages), [])
 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))
Beispiel #4
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_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))
Beispiel #6
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_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]))
 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 getSubscriptionEmailHeaders(self, by_person=False):
     filtered, omitted, messages = construct_email_notifications(
         [self.notification])
     if by_person:
         headers = {}
     else:
         headers = set()
     for message in messages:
         if by_person:
             headers[message['to']] = message.get_all(
                 "X-Launchpad-Subscription", [])
         else:
             headers = headers.union(
                 set(message.get_all(
                     "X-Launchpad-Subscription", [])))
     return headers
 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')
 def test_manage_notifications_message_is_included(self):
     # Set up a subscription to a product.
     subscriber = self.factory.makePerson()
     submitter = self.factory.makePerson()
     product = self.factory.makeProduct(
         bug_supervisor=submitter)
     product.addSubscription(subscriber, subscriber)
     # Create a bug that will match the subscription.
     bug = product.createBug(CreateBugParams(
         title=self.factory.getUniqueString(),
         comment=self.factory.getUniqueString(),
         owner=submitter))
     notification = fetch_notifications(subscriber, bug).one()
     _, _, (message,) = construct_email_notifications([notification])
     payload = message.get_payload()
     self.assertThat(payload, Contains(
         'To manage notifications about this bug go to:\nhttp://'))
 def getSubscriptionEmailBody(self, by_person=False):
     filtered, omitted, messages = construct_email_notifications(
         [self.notification])
     if by_person:
         filter_texts = {}
     else:
         filter_texts = set()
     for message in messages:
         filters_line = None
         for line in message.get_payload().splitlines():
             if line.startswith("Matching subscriptions: "):
                 filters_line = line
                 break
         if filters_line is not None:
             if by_person:
                 filter_texts[message['to']] = filters_line
             else:
                 filter_texts.add(filters_line)
     return filter_texts