|
@@ -10,15 +10,19 @@ class MockRequest(object):
|
|
|
class MentionsTests(AuthenticatedUserTestCase):
|
|
|
def test_single_mention(self):
|
|
|
"""markup extension parses single mention"""
|
|
|
- TEST_CASES = (('<p>Hello, @{}!</p>', '<p>Hello, <a href="{}">@{}</a>!</p>'),
|
|
|
- ('<h1>Hello, @{}!</h1>', '<h1>Hello, <a href="{}">@{}</a>!</h1>'),
|
|
|
- ('<div>Hello, @{}!</div>', '<div>Hello, <a href="{}">@{}</a>!</div>'), (
|
|
|
- '<h1>Hello, <strong>@{}!</strong></h1>',
|
|
|
- '<h1>Hello, <strong><a href="{}">@{}</a>!</strong></h1>'
|
|
|
- ), (
|
|
|
- '<h1>Hello, <strong>@{}</strong>!</h1>',
|
|
|
- '<h1>Hello, <strong><a href="{}">@{}</a></strong>!</h1>'
|
|
|
- ), )
|
|
|
+ TEST_CASES = [
|
|
|
+ ('<p>Hello, @{}!</p>', '<p>Hello, <a href="{}">@{}</a>!</p>'),
|
|
|
+ ('<h1>Hello, @{}!</h1>', '<h1>Hello, <a href="{}">@{}</a>!</h1>'),
|
|
|
+ ('<div>Hello, @{}!</div>', '<div>Hello, <a href="{}">@{}</a>!</div>'),
|
|
|
+ (
|
|
|
+ '<h1>Hello, <strong>@{}!</strong></h1>',
|
|
|
+ '<h1>Hello, <strong><a href="{}">@{}</a>!</strong></h1>'
|
|
|
+ ),
|
|
|
+ (
|
|
|
+ '<h1>Hello, <strong>@{}</strong>!</h1>',
|
|
|
+ '<h1>Hello, <strong><a href="{}">@{}</a></strong>!</h1>'
|
|
|
+ ),
|
|
|
+ ]
|
|
|
|
|
|
for before, after in TEST_CASES:
|
|
|
result = {'parsed_text': before.format(self.user.username), 'mentions': []}
|
|
@@ -49,9 +53,8 @@ class MentionsTests(AuthenticatedUserTestCase):
|
|
|
"""markup extension handles multiple mentions"""
|
|
|
before = '<p>Hello @{0} and @{0}, how is it going?</p>'.format(self.user.username)
|
|
|
|
|
|
- formats = (self.user.get_absolute_url(), self.user.username)
|
|
|
after = '<p>Hello <a href="{0}">@{1}</a> and <a href="{0}">@{1}</a>, how is it going?</p>'.format(
|
|
|
- *formats
|
|
|
+ self.user.get_absolute_url(), self.user.username
|
|
|
)
|
|
|
|
|
|
result = {'parsed_text': before, 'mentions': []}
|
|
@@ -64,9 +67,8 @@ class MentionsTests(AuthenticatedUserTestCase):
|
|
|
"""markup extension handles mentions across document"""
|
|
|
before = '<p>Hello @{0}</p><p>@{0}, how is it going?</p>'.format(self.user.username)
|
|
|
|
|
|
- formats = (self.user.get_absolute_url(), self.user.username)
|
|
|
after = '<p>Hello <a href="{0}">@{1}</a></p><p><a href="{0}">@{1}</a>, how is it going?</p>'.format(
|
|
|
- *formats
|
|
|
+ self.user.get_absolute_url(), self.user.username
|
|
|
)
|
|
|
|
|
|
result = {'parsed_text': before, 'mentions': []}
|