def test_sets_sender_as_reply_to(self): form = LetterForm(data) form.deliver() self.assertIn(data['sender'], mail.outbox[0].extra_headers['Reply-To'])
def test_uses_template(self): form = LetterForm(data) form.deliver() self.assertTrue(mail.outbox[0].body.startswith('A new inquiry:'))
def test_deliver_sets_subject(self): form = LetterForm(data) form.deliver() self.assertEqual(mail.outbox[0].subject, data['subject'])
def test_delivers_message_unchanged(self): form = LetterForm(data) form.deliver() self.assertIn(data['text'], mail.outbox[0].body)
def test_is_valid_with_data(self): form = LetterForm(data) self.assertTrue(form.is_valid())
def test_devliver_send_email(self): form = LetterForm(data) form.deliver() self.assertEqual(1, len(mail.outbox))
def test_requires_sender_subject_text(self): form = LetterForm({}) for field in 'sender subject text'.split(): self.assertIn(field, form.errors)