def test_each_action(self): email_count = 0 for action in self.ACTIONS: # with expected_subject = self._make_subject(action) email_count += 1 # when result = notifications.issue_board_replica(issue=self.issue, action=action) # then self.assertTrue(result) self.assertEqual(len(mail.outbox), email_count) new_email = mail.outbox[-1] self.assertEqual(new_email.subject, expected_subject) self.assertEqual(len(self.expected_recipients), len(new_email.to)) for recipient in self.expected_recipients: self.assertIn(recipient, new_email.to)
def test_each_action_with_disable_notifications_for_editor(self): """ for each action, test notifications are sent, but editor will have disable notifications """ editor_profile = self.editor.get_profile() editor_profile.email_notifications = False editor_profile.save() # update self.expected_recipients self.expected_recipients.remove(editor_profile.user.email) for action in self.ACTIONS: # with expected_subject = self._make_subject(action) # when result = notifications.issue_board_replica(issue=self.issue, action=action) # then # no mail sent, since the only recipient: editor, "choose" to not receive emails self.assertIsNone(result)