Skip to content

Commit

Permalink
[#708] Add more tests to link detection tests
Browse files Browse the repository at this point in the history
  • Loading branch information
domoritz authored and amercader committed Apr 19, 2013
1 parent 2f2a84f commit 6073fa6
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions ckan/tests/misc/test_format_text.py
Expand Up @@ -57,14 +57,14 @@ def test_internal_tag_linked_with_quotes_and_space(self):

def test_internal_tag_with_no_opening_quote_only_matches_single_word(self):
"""Asserts that without an opening quote only one word is matched"""
instr = 'tag:test tag" foobar' # should match 'tag:test'
instr = 'tag:test tag" foobar' # should match 'tag:test'
exp = '<a href="/tag/test">tag:test</a> tag" foobar'
out = h.render_markdown(instr)
assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)

def test_internal_tag_with_no_opening_quote_wont_match_the_closing_quote(self):
"""Asserts that 'tag:test" tag' is matched, but to 'tag:test'"""
instr = 'tag:test" foobar' # should match 'tag:test'
instr = 'tag:test" foobar' # should match 'tag:test'
exp = '<a href="/tag/test">tag:test</a>" foobar'
out = h.render_markdown(instr)
assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
Expand Down Expand Up @@ -111,6 +111,16 @@ def test_normal_link(self):
out = h.render_markdown(instr)
assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)

instr = 'http://somelink.com/#anchor'
exp = '<a href="http://somelink.com/#anchor" target="_blank" rel="nofollow">http://somelink.com/#anchor</a>'
out = h.render_markdown(instr)
assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)

instr = 'http://www.somelink.com/#anchor'
exp = '<a href="http://www.somelink.com/#anchor" target="_blank" rel="nofollow">http://www.somelink.com/#anchor</a>'
out = h.render_markdown(instr)
assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)

def test_auto_link(self):
instr = 'http://somelink.com'
exp = '<a href="http://somelink.com" target="_blank" rel="nofollow">http://somelink.com</a>'
Expand Down

0 comments on commit 6073fa6

Please sign in to comment.