Commits

Branko Vukelic  committed 79b16d8

Basic test for send_html_message

  • Participants
  • Parent commits e93028d

Comments (0)

Files changed (1)

File tests/test_email.py

             {'header1': 'header1 value', 'header2': 'header2 value'},
         )
         self.assertFalse(EMA.return_value.attach_alternative.called,
-                        'Should not attach HTML')
+                         'Should not attach HTML')
+
+
+class SendMessage(TestCase):
+    def test_sending_basically_works(self):
+        msg = Mock()
+        email.send_message(msg)
+        self.assertTrue(msg.send.called,
+                        "Message's send method should be called")
+
+
+class Everything(TestCase):
+    @patch('contact.email.create_message_body')
+    @patch('contact.email.create_message')
+    @patch('contact.email.send_message')
+    def test_send_html_message_basically_works(self, send, cmsg, cbody):
+        cbody.return_value = ('text', 'html')
+        email.send_html_email(
+            'subject',
+            'sender@example.com',
+            'recipient@example.com',
+            'template.html',
+            {'data': 'value'}
+        )
+        self.assertTrue(cmsg.called)
+        self.assertTrue(cbody.called)
+        self.assertTrue(send.called)