Mercurial > public > sg101
view core/tests/test_ssl_images.py @ 871:6900040df0f8
More WIP on ssl_images command & unit test.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Tue, 16 Dec 2014 20:59:49 -0600 |
parents | ee56c8c8cf98 |
children | 1bd9dadcd4d9 |
line wrap: on
line source
"""Unit tests for the ssl_images management command.""" import re import unittest from core.management.commands.ssl_images import process_post class ProcessPostTestCase(unittest.TestCase): SG101_RE = re.compile(r'http://(?:www\.)?surfguitar101.com/', re.I) def test_empty_string(self): s = process_post('') self.assertEqual(s, '') def test_no_matches(self): test_str = """Here is a post that doesn't contain any image links at all. It also spans lines. """ result = process_post(test_str) self.assertEqual(test_str, result) def test_sg101_images(self): test_str = """An image:  And another: . More stuff here.""" expected = self.SG101_RE.sub('/', test_str) result = process_post(test_str) self.assertNotEqual(test_str, expected) self.assertEqual(expected, result) def test_sg101_with_newlines(self): test_str = """An image:  with trailing text.""" expected = """An image:  with trailing text.""" result = process_post(test_str) self.assertNotEqual(test_str, expected) self.assertEqual(expected, result) def test_https_already(self): test_str = """An image that is already using https:  It's cool. """ result = process_post(test_str) self.assertEqual(test_str, result) def test_https_sg101(self): test_str = """An image that is already using https:  It's cool. """ expected = """An image that is already using https:  It's cool. """ result = process_post(test_str) self.assertEqual(expected, result) def test_multiple_non_http(self): test_str = """An image:  And another: . More stuff here.""" expected = """An image:  And another: . More stuff here.""" result = process_post(test_str) self.assertEqual(expected, result) def test_https_already_with_title(self): test_str = """An image that is already using https:  It's cool. """ result = process_post(test_str) self.assertEqual(test_str, result) def test_sg101_with_title(self): test_str = """An image on SG101:  It's cool. """ expected = """An image on SG101:  It's cool. """ result = process_post(test_str) self.assertEqual(expected, result) def test_https_sg101_brackets(self): test_str = """An image that is already using https:  It's cool. """ expected = """An image that is already using https:  It's cool. """ result = process_post(test_str) self.assertEqual(expected, result) def test_https_already_brackets(self): test_str = """An image that is already using https:  It's cool. """ expected = """An image that is already using https:  It's cool. """ result = process_post(test_str) self.assertEqual(expected, result)