2021-01-19 22:33:28 +01:00
|
|
|
import unittest
|
2021-01-19 22:36:20 +01:00
|
|
|
|
2021-01-19 22:33:28 +01:00
|
|
|
from simple_footnotes import parse_for_footnotes
|
|
|
|
|
2021-01-19 22:36:20 +01:00
|
|
|
|
2021-01-19 22:33:28 +01:00
|
|
|
class PseudoArticleGenerator(object):
|
|
|
|
articles = []
|
2021-01-19 22:36:20 +01:00
|
|
|
|
|
|
|
|
2021-01-19 22:33:28 +01:00
|
|
|
class PseudoArticle(object):
|
|
|
|
_content = ""
|
|
|
|
slug = "article"
|
|
|
|
|
|
|
|
|
2021-01-19 22:36:20 +01:00
|
|
|
class TestFootnotes(unittest.TestCase):
|
2021-01-19 22:33:28 +01:00
|
|
|
def _expect(self, input, expected_output):
|
|
|
|
ag = PseudoArticleGenerator()
|
|
|
|
art = PseudoArticle()
|
|
|
|
art._content = input
|
|
|
|
ag.articles = [art]
|
|
|
|
parse_for_footnotes(ag)
|
|
|
|
self.assertEqual(art._content, expected_output)
|
|
|
|
|
|
|
|
def test_simple(self):
|
2021-01-19 22:36:20 +01:00
|
|
|
self._expect(
|
|
|
|
"words[ref]footnote[/ref]end",
|
|
|
|
(
|
|
|
|
'words<sup id="sf-article-1-back"><a title="footnote" '
|
|
|
|
'href="#sf-article-1" class="simple-footnote">1</a></sup>end'
|
|
|
|
'<ol class="simple-footnotes">'
|
|
|
|
u'<li id="sf-article-1">footnote <a href="#sf-article-1-back" class="simple-footnote-back">\u21a9</a></li>'
|
|
|
|
"</ol>"
|
|
|
|
),
|
|
|
|
)
|
2021-01-19 22:33:28 +01:00
|
|
|
|
|
|
|
def test_no_footnote_inside_code(self):
|
2021-01-19 22:36:20 +01:00
|
|
|
self._expect(
|
|
|
|
"words<code>this is code[ref]footnote[/ref] end code </code> end",
|
|
|
|
"words<code>this is code[ref]footnote[/ref] end code </code> end",
|
|
|
|
)
|
|
|
|
|
2021-01-19 22:33:28 +01:00
|
|
|
|
2021-01-19 22:36:20 +01:00
|
|
|
if __name__ == "__main__":
|
|
|
|
unittest.main()
|