comparison 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
comparison
equal deleted inserted replaced
870:ee56c8c8cf98 871:6900040df0f8
27 expected = self.SG101_RE.sub('/', test_str) 27 expected = self.SG101_RE.sub('/', test_str)
28 result = process_post(test_str) 28 result = process_post(test_str)
29 self.assertNotEqual(test_str, expected) 29 self.assertNotEqual(test_str, expected)
30 self.assertEqual(expected, result) 30 self.assertEqual(expected, result)
31 31
32 def test_sg101_with_newlines(self):
33 test_str = """An image: ![image](
34 http://surfguitar101.com/media/zzz.jpg
35 )
36 with trailing text."""
37 expected = """An image: ![image](/media/zzz.jpg)
38 with trailing text."""
39 result = process_post(test_str)
40 self.assertNotEqual(test_str, expected)
41 self.assertEqual(expected, result)
42
32 def test_https_already(self): 43 def test_https_already(self):
33 pass 44 test_str = """An image that is already using https:
45 ![flyer](https://example.com/zzz.png)
46 It's cool.
47 """
48 result = process_post(test_str)
49 self.assertEqual(test_str, result)
50
51 def test_https_sg101(self):
52 test_str = """An image that is already using https:
53 ![flyer](https://www.SURFGUITAR101.com/zzz.png)
54 It's cool.
55 """
56 expected = """An image that is already using https:
57 ![flyer](/zzz.png)
58 It's cool.
59 """
60 result = process_post(test_str)
61 self.assertEqual(expected, result)
62
63 def test_multiple_non_http(self):
64 test_str = """An image: ![image](http://www.surfguitar101.com/img.jpg)
65 And another: ![pic](HTTPS://example.com/foo/bar/img.png).
66 More stuff here."""
67 expected = """An image: ![image](/img.jpg)
68 And another: ![pic](HTTPS://example.com/foo/bar/img.png).
69 More stuff here."""
70 result = process_post(test_str)
71 self.assertEqual(expected, result)
72
73 def test_https_already_with_title(self):
74 test_str = """An image that is already using https:
75 ![flyer](https://example.com/zzz.png "the title")
76 It's cool.
77 """
78 result = process_post(test_str)
79 self.assertEqual(test_str, result)
80
81 def test_sg101_with_title(self):
82 test_str = """An image on SG101:
83 ![flyer](http://surfguitar101.com/zzz.png "the title")
84 It's cool.
85 """
86 expected = """An image on SG101:
87 ![flyer](/zzz.png "the title")
88 It's cool.
89 """
90 result = process_post(test_str)
91 self.assertEqual(expected, result)
92
93 def test_https_sg101_brackets(self):
94 test_str = """An image that is already using https:
95 ![flyer](<https://www.SURFGUITAR101.com/zzz.png>)
96 It's cool.
97 """
98 expected = """An image that is already using https:
99 ![flyer](/zzz.png)
100 It's cool.
101 """
102 result = process_post(test_str)
103 self.assertEqual(expected, result)
104
105 def test_https_already_brackets(self):
106 test_str = """An image that is already using https:
107 ![flyer](<https://example.com/zzz.png>)
108 It's cool.
109 """
110 expected = """An image that is already using https:
111 ![flyer](https://example.com/zzz.png)
112 It's cool.
113 """
114 result = process_post(test_str)
115 self.assertEqual(expected, result)