# HG changeset patch # User Brian Neal # Date 1419219450 21600 # Node ID 1bd9dadcd4d9099c39c4ffdb373443d72df37f54 # Parent 6900040df0f8d8ad1c92ed1a943104c1fda3c22d Added mock-based test for ssl_images command. Also added .tags to .hgignore. diff -r 6900040df0f8 -r 1bd9dadcd4d9 .hgignore --- a/.hgignore Tue Dec 16 20:59:49 2014 -0600 +++ b/.hgignore Sun Dec 21 21:37:30 2014 -0600 @@ -7,6 +7,7 @@ secrets.json *.db *.mp3 +.tags static_serve media/avatars/users media/badges diff -r 6900040df0f8 -r 1bd9dadcd4d9 core/tests/test_ssl_images.py --- 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)