diff core/tests/test_ssl_images.py @ 986:26de15fb5a80

Guard against bad image urls in ssl_images.
author Brian Neal <bgneal@gmail.com>
date Sun, 25 Oct 2015 14:47:29 -0500
parents 4619290d171d
children 76525f5ac2b1
line wrap: on
line diff
--- a/core/tests/test_ssl_images.py	Sun Oct 25 13:54:56 2015 -0500
+++ b/core/tests/test_ssl_images.py	Sun Oct 25 14:47:29 2015 -0500
@@ -234,6 +234,15 @@
         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.save_image_to_cloud')
+    def test_bad_image_url(self, upload_mock):
+        test_str = u'![image](http://[url=http://www.flickr.com/photos/85447101@N04/8025176073/][img]http://farm9.staticflickr.com/8456/8025176073_91ac0c3d18_b.jpg[/img][/url] [url=http://www.flickr.com/photos/85447101@N04/8025176073/]IMG_0398[/url] by [url=http://www.flickr.com/people/85447101@N04/]friendshipmaster[/url], on Flick)'
+        expected = u'{bad image}'
+
+        result = process_post(test_str)
+        self.assertEqual(expected, result)
+        self.assertEqual(upload_mock.call_count, 0)
+
 
 class HtmlCheckTestCase(unittest.TestCase):