bgneal@868: """Unit tests for the ssl_images management command.""" bgneal@870: import re bgneal@868: import unittest bgneal@868: bgneal@868: from core.management.commands.ssl_images import process_post bgneal@868: bgneal@868: bgneal@868: class ProcessPostTestCase(unittest.TestCase): bgneal@868: bgneal@870: SG101_RE = re.compile(r'http://(?:www\.)?surfguitar101.com/', re.I) bgneal@870: bgneal@868: def test_empty_string(self): bgneal@868: s = process_post('') bgneal@868: self.assertEqual(s, '') bgneal@870: bgneal@870: def test_no_matches(self): bgneal@870: test_str = """Here is a post that doesn't contain any image links at bgneal@870: all. It also spans lines. bgneal@870: """ bgneal@870: result = process_post(test_str) bgneal@870: self.assertEqual(test_str, result) bgneal@870: bgneal@870: def test_sg101_images(self): bgneal@870: test_str = """An image: ![image](http://www.surfguitar101.com/img.jpg) bgneal@870: And another: ![pic](HTTP://SURFGUITAR101.COM/foo/bar/img.png). bgneal@870: More stuff here.""" bgneal@870: expected = self.SG101_RE.sub('/', test_str) bgneal@870: result = process_post(test_str) bgneal@870: self.assertNotEqual(test_str, expected) bgneal@870: self.assertEqual(expected, result) bgneal@870: bgneal@870: def test_https_already(self): bgneal@870: pass