Mercurial > public > sg101
comparison 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 |
comparison
equal
deleted
inserted
replaced
985:9b197dbba34b | 986:26de15fb5a80 |
---|---|
231 upload_mock.side_effect = new_src | 231 upload_mock.side_effect = new_src |
232 result = process_post(test_str) | 232 result = process_post(test_str) |
233 self.assertEqual(expected, result) | 233 self.assertEqual(expected, result) |
234 expected_args = [mock.call(urlparse(c)) for c in old_src[:2]] | 234 expected_args = [mock.call(urlparse(c)) for c in old_src[:2]] |
235 self.assertEqual(upload_mock.call_args_list, expected_args) | 235 self.assertEqual(upload_mock.call_args_list, expected_args) |
236 | |
237 @mock.patch('core.management.commands.ssl_images.save_image_to_cloud') | |
238 def test_bad_image_url(self, upload_mock): | |
239 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)' | |
240 expected = u'{bad image}' | |
241 | |
242 result = process_post(test_str) | |
243 self.assertEqual(expected, result) | |
244 self.assertEqual(upload_mock.call_count, 0) | |
236 | 245 |
237 | 246 |
238 class HtmlCheckTestCase(unittest.TestCase): | 247 class HtmlCheckTestCase(unittest.TestCase): |
239 | 248 |
240 def test_empty(self): | 249 def test_empty(self): |