diff core/tests/test_ssl_images.py @ 872:1bd9dadcd4d9

Added mock-based test for ssl_images command. Also added .tags to .hgignore.
author Brian Neal <bgneal@gmail.com>
date Sun, 21 Dec 2014 21:37:30 -0600
parents 6900040df0f8
children 9676833dfdca
line wrap: on
line diff
--- a/core/tests/test_ssl_images.py	Tue Dec 16 20:59:49 2014 -0600
+++ b/core/tests/test_ssl_images.py	Sun Dec 21 21:37:30 2014 -0600
@@ -2,6 +2,8 @@
 import re
 import unittest
 
+import mock
+
 from core.management.commands.ssl_images import process_post
 
 
@@ -113,3 +115,19 @@
             """
         result = process_post(test_str)
         self.assertEqual(expected, result)
+
+    @mock.patch('core.management.commands.ssl_images.save_image_to_cloud')
+    def test_simple_replacement(self, upload_mock):
+        old_src = 'http://example.com/images/my_image.jpg'
+        new_src = 'ttps://cloud.com/ABCDEF.jpg'
+        test_str = """Here is a really cool http: based image:
+            ![flyer]({})
+            Cool, right?""".format(old_src)
+        expected = """Here is a really cool http: based image:
+            ![flyer]({})
+            Cool, right?""".format(new_src)
+
+        upload_mock.return_value = new_src
+        result = process_post(test_str)
+        self.assertEqual(expected, result)
+        upload_mock.assert_called_once_with(old_src)