annotate core/tests/test_mdexts.py @ 953:8647a669edb4

Fix excessive cache usage for forum date/times. Issue #84. Hitting the cache 30+ times while browsing the forums to adjust all the dates/times into the user's time zone. Just hit the user's profile and be done with it. It should be loaded.
author Brian Neal <bgneal@gmail.com>
date Tue, 19 May 2015 21:08:45 -0500
parents f12751259f66
children
rev   line source
bgneal@883 1 """Testing our custom Markdown extensions."""
bgneal@883 2
bgneal@883 3 import unittest
bgneal@883 4
bgneal@883 5 import markdown
bgneal@883 6
bgneal@883 7 from core.mdexts.ssl_images import SslImagesExtension
bgneal@883 8
bgneal@883 9
bgneal@883 10 class SslImagesExtTestCase(unittest.TestCase):
bgneal@883 11 """Tests for the SslImagesExtension."""
bgneal@883 12
bgneal@883 13 def setUp(self):
bgneal@883 14 self.md = markdown.Markdown(extensions=[SslImagesExtension()])
bgneal@883 15
bgneal@883 16 def test_simple(self):
bgneal@883 17 self.assertEqual(self.md.convert(''), '')
bgneal@883 18 self.assertEqual(self.md.convert('1'), '<p>1</p>')
bgneal@883 19
bgneal@883 20 def test_no_change(self):
bgneal@883 21 self.assertEqual(self.md.convert('![image](https://example.com/1.jpg)'),
bgneal@883 22 u'<p><img alt="image" src="https://example.com/1.jpg" /></p>')
bgneal@883 23
bgneal@883 24 def test_change(self):
bgneal@883 25 text = u'![image](http://example.com/1.jpg)'
bgneal@883 26 html = u'<p><a href="http://example.com/1.jpg">Click for image</a></p>'
bgneal@883 27 self.assertEqual(self.md.convert(text), html)