test_simple_footnotes.py 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. import unittest
  2. from simple_footnotes import parse_for_footnotes
  3. class PseudoArticleGenerator(object):
  4. articles = []
  5. class PseudoArticle(object):
  6. _content = ""
  7. slug = "article"
  8. class TestFootnotes(unittest.TestCase):
  9. def _expect(self, input, expected_output):
  10. ag = PseudoArticleGenerator()
  11. art = PseudoArticle()
  12. art._content = input
  13. ag.articles = [art]
  14. parse_for_footnotes(ag)
  15. self.assertEqual(art._content, expected_output)
  16. def test_simple(self):
  17. self._expect("words[ref]footnote[/ref]end",
  18. ('words<sup id="sf-article-1-back"><a title="footnote" '
  19. 'href="#sf-article-1" class="simple-footnote">1</a></sup>end'
  20. '<ol class="simple-footnotes">'
  21. u'<li id="sf-article-1">footnote <a href="#sf-article-1-back" class="simple-footnote-back">\u21a9</a></li>'
  22. '</ol>'))
  23. def test_no_footnote_inside_code(self):
  24. self._expect("words<code>this is code[ref]footnote[/ref] end code </code> end",
  25. "words<code>this is code[ref]footnote[/ref] end code </code> end")
  26. if __name__ == '__main__':
  27. unittest.main()