comparison core/tests/test_ssl_images.py @ 870:ee56c8c8cf98

More WIP on ssl_images management command and tests.
author Brian Neal <bgneal@gmail.com>
date Mon, 15 Dec 2014 21:16:47 -0600
parents 64a5acb83937
children 6900040df0f8
comparison
equal deleted inserted replaced
869:63209e53f3aa 870:ee56c8c8cf98
1 """Unit tests for the ssl_images management command.""" 1 """Unit tests for the ssl_images management command."""
2 2 import re
3 import unittest 3 import unittest
4 4
5 from core.management.commands.ssl_images import process_post 5 from core.management.commands.ssl_images import process_post
6 6
7 7
8 class ProcessPostTestCase(unittest.TestCase): 8 class ProcessPostTestCase(unittest.TestCase):
9 9
10 SG101_RE = re.compile(r'http://(?:www\.)?surfguitar101.com/', re.I)
11
10 def test_empty_string(self): 12 def test_empty_string(self):
11 s = process_post('') 13 s = process_post('')
12 self.assertEqual(s, '') 14 self.assertEqual(s, '')
15
16 def test_no_matches(self):
17 test_str = """Here is a post that doesn't contain any image links at
18 all. It also spans lines.
19 """
20 result = process_post(test_str)
21 self.assertEqual(test_str, result)
22
23 def test_sg101_images(self):
24 test_str = """An image: ![image](http://www.surfguitar101.com/img.jpg)
25 And another: ![pic](HTTP://SURFGUITAR101.COM/foo/bar/img.png).
26 More stuff here."""
27 expected = self.SG101_RE.sub('/', test_str)
28 result = process_post(test_str)
29 self.assertNotEqual(test_str, expected)
30 self.assertEqual(expected, result)
31
32 def test_https_already(self):
33 pass