22
27
self.res = do_wl_markdown(self.input)
24
class TestWlMarkdown_SimpleCase_ExceptCorrectResult(_TestWlMarkdown_Base):
26
wanted = u"<p>Hallo Welt</p>\n"
28
self.assertEqual(self.wanted,self.res)
29
# WlMarkup doesn't do urlization
30
# class TestWlMarkdown_AutoLinkHTTP_ExceptCorrectResult(_TestWlMarkdown_Base):
31
# input = u"Sun: http://www.sun.com"
32
# wanted = u"""<p>Sun: <a href="http://www.sun.com">http://www.sun.com</a></p>\n"""
34
# self.assertEqual(self.wanted,self.res)
35
class TestWlMarkdown_WikiWordsSimple_ExceptCorrectResult(_TestWlMarkdown_Base):
36
input = u"Na Du HalloWelt, Du?"
37
wanted = u"""<p>Na Du <a href="/wiki/HalloWelt">HalloWelt</a>, Du?</p>\n"""
39
self.assertEqual(self.wanted,self.res)
40
class TestWlMarkdown_WikiWordsAvoid_ExceptCorrectResult(_TestWlMarkdown_Base):
41
input = u"Hi !NotAWikiWord Moretext"
42
wanted = u"""<p>Hi NotAWikiWord Moretext</p>\n"""
44
self.assertEqual(self.wanted,self.res)
45
class TestWlMarkdown_WikiWordsInLink_ExceptCorrectResult(_TestWlMarkdown_Base):
46
input = u"""WikiWord [NoWikiWord](http://www.sun.com)"""
47
wanted = u"""<p><a href="/wiki/WikiWord">WikiWord</a> <a href="http://www.sun.com">NoWikiWord</a></p>\n"""
49
self.assertEqual(self.wanted,self.res)
29
class TestWlMarkdown(DBTestCase):
31
a = Article.objects.create(title="MainPage")
32
a = Article.objects.create(title="HalloWelt")
33
a = Article.objects.create(title="NoWikiWord")
34
a = Article.objects.create(title="WikiWord")
36
def _check(self, input, wanted):
37
res = do_wl_markdown(input)
38
self.assertEqual(wanted,res)
40
def test_simple_case__correct_result(self):
42
wanted = u"<p>Hallo Welt</p>\n"
43
self._check(input,wanted)
45
def test_wikiwords_simple__except_correct_result(self):
46
input = u"Na Du HalloWelt, Du?"
47
wanted = u"""<p>Na Du <a href="/wiki/HalloWelt">HalloWelt</a>, Du?</p>\n"""
48
self._check(input,wanted)
50
def test_wikiwords_avoid__except_correct_result(self):
51
input = u"Hi !NotAWikiWord Moretext"
52
wanted = u"""<p>Hi NotAWikiWord Moretext</p>\n"""
53
self._check(input,wanted)
55
def test_wikiwords_in_link__except_correct_result(self):
56
input = u"""WikiWord [NoWikiWord](/forum/)"""
57
wanted = u"""<p><a href="/wiki/WikiWord">WikiWord</a> <a href="/forum/">NoWikiWord</a></p>\n"""
58
self._check(input,wanted)
60
def test_wikiwords_external_links__except_correct_result(self):
61
input = u"""[NoWikiWord](http://www.sun.com)"""
62
wanted = u"""<p><a href="http://www.sun.com" class="external">NoWikiWord</a></p>\n"""
63
self._check(input,wanted)
65
def test_wikiwords_noexternal_links__except_correct_result(self):
66
input = u"""[NoWikiWord](http://%s/blahfasel/wiki)""" % _domain
67
wanted = u"""<p><a href="http://%s/blahfasel/wiki">NoWikiWord</a></p>\n""" %_domain
68
self._check(input,wanted)
70
def test_wikiwords_noclasschangeforimage_links__except_correct_result(self):
71
input = u"""<a href="http://www.ccc.de"><img src="/blub" /></a>"""
72
wanted = u"""<p><a href="http://www.ccc.de"><img src="/blub" /></a></p>\n"""
73
self._check(input,wanted)
76
def test_existing_link_html(self):
77
input = u"""<a href="/wiki/MainPage">this page</a>"""
78
wanted = u"""<p><a href="/wiki/MainPage">this page</a></p>\n"""
79
self._check(input,wanted)
81
def test_existing_link_markdown(self):
82
input = u"""[this page](/wiki/MainPage)"""
83
wanted = u"""<p><a href="/wiki/MainPage">this page</a></p>\n"""
84
self._check(input,wanted)
86
def test_existing_link_wikiword(self):
87
input = u"""MainPage"""
88
wanted = u"""<p><a href="/wiki/MainPage">MainPage</a></p>\n"""
89
self._check(input,wanted)
91
def test_existing_editlink_wikiword(self):
92
input = u"""<a href="/wiki/MainPage/edit/">this page</a>"""
93
wanted = u"""<p><a href="/wiki/MainPage/edit/">this page</a></p>\n"""
94
self._check(input,wanted)
97
def test_missing_link_html(self):
98
input = u"""<a href="/wiki/MissingPage">this page</a>"""
99
wanted = u"""<p><a href="/wiki/MissingPage" class="missing">this page</a></p>\n"""
100
self._check(input,wanted)
102
def test_missing_link_markdown(self):
103
input = u"""[this page](/wiki/MissingPage)"""
104
wanted = u"""<p><a href="/wiki/MissingPage" class="missing">this page</a></p>\n"""
105
self._check(input,wanted)
107
def test_missing_link_wikiword(self):
108
input = u"""BlubMissingPage"""
109
wanted = u"""<p><a href="/wiki/BlubMissingPage" class="missing">BlubMissingPage</a></p>\n"""
110
res = do_wl_markdown(input)
111
# self._check(input,wanted)
113
def test_missing_editlink_wikiword(self):
114
input = u"""<a href="/wiki/MissingPage/edit/">this page</a>"""
115
wanted = u"""<p><a href="/wiki/MissingPage/edit/" class="missing">this page</a></p>\n"""
116
self._check(input,wanted)
52
118
if __name__ == '__main__':