update email tests now that we validate authorizations.
@@ -185,6 +185,12 @@ class ApplicationCommentTest(TestCase):
class ApplicationStatusTest(TestCase):
+ def setUp(self):
+ super(ApplicationStatusTest, self).setUp()
+ self.coordinator = EditorFactory().user
+ coordinators = get_coordinators()
+ coordinators.user_set.add(self.coordinator)
+
@patch("TWLight.emails.tasks.send_approval_notification_email")
def test_approval_calls_email_function(self, mock_email):
app = ApplicationFactory(status=Application.PENDING)
@@ -240,7 +246,7 @@ class ApplicationStatusTest(TestCase):
Applications saved with a SENT status should not generate email.
"""
orig_outbox = len(mail.outbox)
- _ = ApplicationFactory(status=Application.SENT)
+ ApplicationFactory(status=Application.SENT, sent_by=self.coordinator)
self.assertEqual(len(mail.outbox), orig_outbox)
@patch("TWLight.emails.tasks.send_waitlist_notification_email")
@@ -292,7 +298,9 @@ class ApplicationStatusTest(TestCase):
partner = PartnerFactory(status=Partner.AVAILABLE)
app = ApplicationFactory(status=Application.APPROVED, partner=partner)
app = ApplicationFactory(status=Application.NOT_APPROVED, partner=partner)
- app = ApplicationFactory(status=Application.SENT, partner=partner)
+ app = ApplicationFactory(
+ status=Application.SENT, partner=partner, sent_by=self.coordinator
+ )
self.assertFalse(mock_email.called)
partner.status = Partner.WAITLIST
@@ -511,7 +519,10 @@ class CoordinatorReminderEmailTest(TestCase):
partner=self.partner, status=Application.APPROVED, editor=self.user2.editor
)
ApplicationFactory(
- partner=self.partner2, status=Application.SENT, editor=self.user.editor
+ partner=self.partner2,
+ status=Application.SENT,
+ editor=self.user.editor,
+ sent_by=self.coordinator,
)
# Clear mail outbox since approvals send emails
