test_parser.py
35 lines
| 1.2 KiB
| text/x-python
|
PythonLexer
neko259
|
r886 | from django.test import TestCase | ||
neko259
|
r1066 | from boards.mdx_neboard import Parser | ||
neko259
|
r886 | from boards.models import Post | ||
class ParserTest(TestCase): | ||||
def test_preparse_quote(self): | ||||
neko259
|
r887 | raw_text = '>quote\nQuote in >line\nLine\n>Quote' | ||
neko259
|
r1066 | preparsed_text = Parser().preparse(raw_text) | ||
neko259
|
r886 | |||
neko259
|
r887 | self.assertEqual( | ||
'[quote]quote[/quote]\nQuote in >line\nLine\n[quote]Quote[/quote]', | ||||
neko259
|
r888 | preparsed_text, 'Quote not preparsed.') | ||
def test_preparse_comment(self): | ||||
raw_text = '//comment' | ||||
neko259
|
r1066 | preparsed_text = Parser().preparse(raw_text) | ||
neko259
|
r888 | |||
self.assertEqual('[comment]comment[/comment]', preparsed_text, | ||||
neko259
|
r926 | 'Comment not preparsed.') | ||
def test_preparse_reflink(self): | ||||
raw_text = '>>12\nText' | ||||
neko259
|
r1066 | preparsed_text = Parser().preparse(raw_text) | ||
neko259
|
r926 | |||
self.assertEqual('[post]12[/post]\nText', | ||||
preparsed_text, 'Reflink not preparsed.') | ||||
neko259
|
r1002 | def preparse_user(self): | ||
raw_text = '@user\nuser@example.com\n@user\nuser @user' | ||||
neko259
|
r1066 | preparsed_text = Parser().preparse(raw_text) | ||
neko259
|
r1002 | |||
self.assertEqual('[user]user[/user]\nuser@example.com\n[user]user[/user]\nuser [user]user[/user]', | ||||
preparsed_text, 'User link not preparsed.') | ||||