comparison core/tests/test_mdexts.py @ 883:f12751259f66

Add a Markdown extension to only allow https based <img> tags. This is not yet "turned on" in the site's markup system.
author Brian Neal <bgneal@gmail.com>
date Tue, 03 Feb 2015 19:51:12 -0600
parents
children
comparison
equal deleted inserted replaced
882:9a3019f2c7dc 883:f12751259f66
1 """Testing our custom Markdown extensions."""
2
3 import unittest
4
5 import markdown
6
7 from core.mdexts.ssl_images import SslImagesExtension
8
9
10 class SslImagesExtTestCase(unittest.TestCase):
11 """Tests for the SslImagesExtension."""
12
13 def setUp(self):
14 self.md = markdown.Markdown(extensions=[SslImagesExtension()])
15
16 def test_simple(self):
17 self.assertEqual(self.md.convert(''), '')
18 self.assertEqual(self.md.convert('1'), '<p>1</p>')
19
20 def test_no_change(self):
21 self.assertEqual(self.md.convert('![image](https://example.com/1.jpg)'),
22 u'<p><img alt="image" src="https://example.com/1.jpg" /></p>')
23
24 def test_change(self):
25 text = u'![image](http://example.com/1.jpg)'
26 html = u'<p><a href="http://example.com/1.jpg">Click for image</a></p>'
27 self.assertEqual(self.md.convert(text), html)