Commits

Branko Vukelic committed 79b16d8

Basic test for send_html_message

Comments (0)

Files changed (1)

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)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.