changeset 927:37e75385e931

Fix broken ssl_images unit test. This was broken before the upgrade to Django 1.7.7.
author Brian Neal <bgneal@gmail.com>
date Tue, 14 Apr 2015 21:25:43 -0500 (2015-04-15)
parents 22ed8451e163
children 4d26a46f1b86
files core/tests/test_ssl_images.py
diffstat 1 files changed, 4 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/core/tests/test_ssl_images.py	Sun Apr 12 21:19:22 2015 -0500
+++ b/core/tests/test_ssl_images.py	Tue Apr 14 21:25:43 2015 -0500
@@ -123,8 +123,6 @@
         self.assertEqual(expected, result)
 
     @mock.patch('core.management.commands.ssl_images.save_image_to_cloud')
-    @mock.patch('core.management.commands.ssl_images.check_https_availability',
-                new=lambda r: None)
     def test_simple_replacement(self, upload_mock):
         old_src = 'http://example.com/images/my_image.jpg'
         new_src = 'https://cloud.com/ABCDEF.jpg'
@@ -138,11 +136,9 @@
         upload_mock.return_value = new_src
         result = process_post(test_str)
         self.assertEqual(expected, result)
-        upload_mock.assert_called_once_with(old_src)
+        upload_mock.assert_called_once_with(urlparse(old_src))
 
     @mock.patch('core.management.commands.ssl_images.save_image_to_cloud')
-    @mock.patch('core.management.commands.ssl_images.check_https_availability',
-                new=lambda r: None)
     def test_multiple_replacement(self, upload_mock):
         old_src = [
             'http://example.com/images/my_image.jpg',
@@ -169,12 +165,10 @@
         upload_mock.side_effect = new_src
         result = process_post(test_str)
         self.assertEqual(expected, result)
-        expected_args = [mock.call(c) for c in old_src]
+        expected_args = [mock.call(urlparse(c)) for c in old_src]
         self.assertEqual(upload_mock.call_args_list, expected_args)
 
     @mock.patch('core.management.commands.ssl_images.save_image_to_cloud')
-    @mock.patch('core.management.commands.ssl_images.check_https_availability',
-                new=lambda r: None)
     def test_multiple_replacement_2(self, upload_mock):
         old_src = [
             'http://example.com/images/my_image.jpg',
@@ -203,11 +197,9 @@
         upload_mock.side_effect = new_src
         result = process_post(test_str)
         self.assertEqual(expected, result)
-        upload_mock.assert_called_once_with(old_src[0])
+        upload_mock.assert_called_once_with(urlparse(old_src[0]))
 
     @mock.patch('core.management.commands.ssl_images.save_image_to_cloud')
-    @mock.patch('core.management.commands.ssl_images.check_https_availability',
-                new=lambda r: None)
     def test_caching(self, upload_mock):
         old_src = [
             'http://example.com/images/my_image.jpg',
@@ -234,39 +226,9 @@
         upload_mock.side_effect = new_src
         result = process_post(test_str)
         self.assertEqual(expected, result)
-        expected_args = [mock.call(c) for c in old_src[:2]]
+        expected_args = [mock.call(urlparse(c)) for c in old_src[:2]]
         self.assertEqual(upload_mock.call_args_list, expected_args)
 
-    @mock.patch('core.management.commands.ssl_images.check_https_availability')
-    def test_https_availability(self, check_https_mock):
-        old_src = [
-            'http://example.com/images/my_image.jpg',
-            'http://example.com/static/wow.gif',
-            'http://example.com/images/another_image.jpg',
-        ]
-        new_src = [
-            'https://example.com/images/my_image.jpg',
-            'https://example.com/static/wow.gif',
-            'https://example.com/images/another_image.jpg',
-        ]
-
-        template = """Here is a really cool http: based image:
-            ![flyer]({})
-            Cool, right?
-            Another one: ![pic]({})
-            And finally
-            ![an image]({})
-            """
-
-        test_str = template.format(*old_src)
-        expected = template.format(*new_src)
-
-        check_https_mock.side_effect = new_src
-        result = process_post(test_str)
-        self.assertEqual(expected, result)
-        expected_args = [mock.call(urlparse(c)) for c in old_src]
-        self.assertEqual(check_https_mock.call_args_list, expected_args)
-
 
 class HtmlCheckTestCase(unittest.TestCase):