def test_each_action_with_disable_notifications_for_one_librarian(self): """ for each action, test notifications are sent, but librarian2 will have disable notifications """ librarian2_profile = self.librarian2.get_profile() librarian2_profile.email_notifications = False librarian2_profile.save() # remove it from expected_bcc_recipients self.expected_bcc_recipients.remove(librarian2_profile.user.email) email_count = 0 for action in self.ACTIONS: # with expected_subject = self._make_subject(action) message = 'Audit Log change message goes here!' email_count += 1 # when result = notifications.board_members_send_email_by_action(self.member, self.editor, message, 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)) self.assertEqual(len(self.expected_bcc_recipients), len(new_email.bcc)) for recipient in self.expected_recipients: self.assertIn(recipient, new_email.to) for recipient in self.expected_bcc_recipients: self.assertIn(recipient, new_email.bcc)
def test_each_action(self): email_count = 0 for action in self.ACTIONS: # with expected_subject = self._make_subject(action) message = 'Audit Log change message goes here!' email_count += 1 # when result = notifications.board_members_send_email_by_action(self.member, self.editor, message, 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)) self.assertEqual(len(self.expected_bcc_recipients), len(new_email.bcc)) for recipient in self.expected_recipients: self.assertIn(recipient, new_email.to) for recipient in self.expected_bcc_recipients: self.assertIn(recipient, new_email.bcc)