コード例 #1
0
ファイル: test_format_text.py プロジェクト: usuariobkp/ckan
 def test_internal_tag_link(self):
     """Asserts links like 'tag:test-tag' work"""
     instr = 'tag:test-tag foobar'
     exp = '<a href="/tag/test-tag">tag:test-tag</a> foobar'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
コード例 #2
0
ファイル: test_format_text.py プロジェクト: usuariobkp/ckan
 def test_internal_tag_linked_with_quotes_and_space(self):
     """Asserts links like 'tag:"test tag"' work"""
     instr = 'tag:"test tag" foobar'
     exp = '<a href="/tag/test%20tag">tag:"test tag"</a> foobar'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
コード例 #3
0
ファイル: test_format_text.py プロジェクト: kindly/ckantest
    def test_evil_markdown(self):
        instr = 'Evil <script src="http://evilserver.net/evil.js";>'
        exp = '''<p>Evil [HTML_REMOVED]
</p>'''
        format = MarkdownFormat()
        out = format.to_html(instr)
        assert out == exp, out
コード例 #4
0
 def test_malformed_link_3(self):
     instr = u'<a href="http://url.com"> url'
     exp = '<a href="http://url.com" target="_blank" rel="nofollow"> url'
     # NB when this is put into Genshi, it will close the tag for you.
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
コード例 #5
0
 def test_tag_names_with_unicode_alphanumeric(self):
     """Asserts that unicode alphanumeric characters are captured"""
     instr = u'tag:"Japanese katakana \u30a1" blah'
     exp = u'<a href="/tag/Japanese%20katakana%20%E3%82%A1">tag:"Japanese katakana \u30a1"</a>'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, u'\nGot: %s\nWanted: %s' % (out, exp)
コード例 #6
0
ファイル: test_format_text.py プロジェクト: usuariobkp/ckan
 def test_tag_names_with_unicode_alphanumeric(self):
     """Asserts that unicode alphanumeric characters are captured"""
     instr = u'tag:"Japanese katakana \u30a1" blah'
     exp = u'<a href="/tag/Japanese%20katakana%20%E3%82%A1">tag:"Japanese katakana \u30a1"</a>'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, u'\nGot: %s\nWanted: %s' % (out, exp)
コード例 #7
0
 def test_tag_names_match_simple_punctuation(self):
     """Asserts punctuation and capital letters are matched in the tag name"""
     instr = 'tag:"Test- _." foobar'
     exp = '<a href="/tag/Test-%20_.">tag:"Test- _."</a> foobar'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
コード例 #8
0
 def test_tag_names_do_not_match_commas(self):
     """Asserts commas don't get matched as part of a tag name"""
     instr = 'tag:Test,tag foobar'
     exp = '<a href="/tag/Test">tag:Test</a>,tag foobar'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
コード例 #9
0
 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'
     exp = '<a href="/tag/test">tag:test</a>" foobar'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
コード例 #10
0
ファイル: test_format_text.py プロジェクト: kindly/ckantest
 def test_malformed_link_3(self):
     instr = u'<a href="http://url.com"> url'
     exp = '<a href="http://url.com" target="_blank" rel="nofollow"> url'
     # NB when this is put into Genshi, it will close the tag for you.
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
コード例 #11
0
 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'
     exp = '<a href="/tag/test">tag:test</a> tag" foobar'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
コード例 #12
0
 def test_internal_tag_linked_with_quotes_and_space(self):
     """Asserts links like 'tag:"test tag"' work"""
     instr = 'tag:"test tag" foobar'
     exp = '<a href="/tag/test%20tag">tag:"test tag"</a> foobar'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
コード例 #13
0
 def test_internal_tag_link(self):
     """Asserts links like 'tag:test-tag' work"""
     instr = 'tag:test-tag foobar'
     exp = '<a href="/tag/test-tag">tag:test-tag</a> foobar'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
コード例 #14
0
ファイル: test_format_text.py プロジェクト: usuariobkp/ckan
 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'
     exp = '<a href="/tag/test">tag:test</a> tag" foobar'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
コード例 #15
0
ファイル: test_format_text.py プロジェクト: usuariobkp/ckan
 def test_tag_names_match_simple_punctuation(self):
     """Asserts punctuation and capital letters are matched in the tag name"""
     instr = 'tag:"Test- _." foobar'
     exp = '<a href="/tag/Test-%20_.">tag:"Test- _."</a> foobar'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
コード例 #16
0
ファイル: test_format_text.py プロジェクト: usuariobkp/ckan
 def test_tag_names_do_not_match_commas(self):
     """Asserts commas don't get matched as part of a tag name"""
     instr = 'tag:Test,tag foobar'
     exp = '<a href="/tag/Test">tag:Test</a>,tag foobar'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
コード例 #17
0
    def test_evil_markdown(self):
        instr = 'Evil <script src="http://evilserver.net/evil.js";>'
        exp = '''<p>Evil [HTML_REMOVED]
</p>'''
        format = MarkdownFormat()
        out = format.to_html(instr)
        assert out == exp, out
コード例 #18
0
ファイル: test_format_text.py プロジェクト: usuariobkp/ckan
 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'
     exp = '<a href="/tag/test">tag:test</a>" foobar'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
コード例 #19
0
ファイル: test_format_text.py プロジェクト: usuariobkp/ckan
 def test_tag_names_dont_match_non_space_whitespace(self):
     """Asserts that the only piece of whitespace matched in a tagname is a space"""
     whitespace_characters = '\t\n\r\f\v'
     for ch in whitespace_characters:
         instr = 'tag:Bad' + ch + 'space'
         exp = '<a href="/tag/Bad">tag:Bad</a>'
         format = MarkdownFormat()
         out = format.to_html(instr)
         assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
コード例 #20
0
 def test_tag_names_dont_match_non_space_whitespace(self):
     """Asserts that the only piece of whitespace matched in a tagname is a space"""
     whitespace_characters = '\t\n\r\f\v'
     for ch in whitespace_characters:
         instr = 'tag:Bad' + ch + 'space'
         exp = '<a href="/tag/Bad">tag:Bad</a>'
         format = MarkdownFormat()
         out = format.to_html(instr)
         assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
コード例 #21
0
ファイル: test_format_text.py プロジェクト: usuariobkp/ckan
    def test_multiline_links(self):
        instr = u'''I get 10 times more traffic from [Google][] than from
[Yahoo][] or [MSN][].

  [google]: http://google.com/        "Google"
  [yahoo]:  http://search.yahoo.com/  "Yahoo Search"
  [msn]:    http://search.msn.com/    "MSN Search"'''
        exp = '''I get 10 times more traffic from <a href="http://google.com/" title="Google">Google</a> than from
   <a href="http://search.yahoo.com/" title="Yahoo Search">Yahoo</a> or <a href="http://search.msn.com/" title="MSN Search">MSN</a>.'''
        # NB when this is put into Genshi, it will close the tag for you.
        format = MarkdownFormat()
        out = format.to_html(instr)
        assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
コード例 #22
0
ファイル: test_format_text.py プロジェクト: kindly/ckantest
    def test_multiline_links(self):
        instr = u'''I get 10 times more traffic from [Google][] than from
[Yahoo][] or [MSN][].

  [google]: http://google.com/        "Google"
  [yahoo]:  http://search.yahoo.com/  "Yahoo Search"
  [msn]:    http://search.msn.com/    "MSN Search"'''
        exp = '''I get 10 times more traffic from <a href="http://google.com/" title="Google">Google</a> than from
   <a href="http://search.yahoo.com/" title="Yahoo Search">Yahoo</a> or <a href="http://search.msn.com/" title="MSN Search">MSN</a>.'''
        # NB when this is put into Genshi, it will close the tag for you.
        format = MarkdownFormat()
        out = format.to_html(instr)
        assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
コード例 #23
0
    def test_markdown(self):
        instr = '''# Hello World

**Some bolded text.**

*Some italicized text.*
'''
        exp = '''<h1>Hello World</h1>
<p><strong>Some bolded text.</strong>
</p>
<p><em>Some italicized text.</em>
</p>'''
        format = MarkdownFormat()
        out = format.to_html(instr)
        assert out == exp
コード例 #24
0
ファイル: test_format_text.py プロジェクト: kindly/ckantest
    def test_markdown(self):
        instr = '''# Hello World

**Some bolded text.**

*Some italicized text.*
'''
        exp = '''<h1>Hello World</h1>
<p><strong>Some bolded text.</strong>
</p>
<p><em>Some italicized text.</em>
</p>'''
        format = MarkdownFormat()
        out = format.to_html(instr)
        assert out == exp
コード例 #25
0
ファイル: test_format_text.py プロジェクト: kindly/ckantest
 def test_malformed_link_2(self):
     instr = u'<a href="http://url.com> url >'
     exp = '<a href="TAG MALFORMED" target="_blank" rel="nofollow"> url &gt;'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
コード例 #26
0
ファイル: test_format_text.py プロジェクト: kindly/ckantest
 def test_malformed_link_1(self):
     instr = u'<a href=\u201dsomelink\u201d>somelink</a>'
     exp = '<a href="TAG MALFORMED" target="_blank" rel="nofollow">somelink</a>'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
コード例 #27
0
ファイル: test_format_text.py プロジェクト: kindly/ckantest
 def test_auto_link_after_whitespace(self):
     instr = 'go to http://somelink.com'
     exp = 'go to <a href="http://somelink.com" target="_blank" rel="nofollow">http://somelink.com</a>'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
コード例 #28
0
ファイル: test_format_text.py プロジェクト: kindly/ckantest
 def test_normal_link(self):
     instr = '<http://somelink/>'
     exp = '<a href="http://somelink/" target="_blank" rel="nofollow">http://somelink/</a>'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
コード例 #29
0
ファイル: test_format_text.py プロジェクト: kindly/ckantest
 def test_internal_link(self):
     instr = 'package:test-_pkg'
     exp = '<a href="/package/test-_pkg">package:test-_pkg</a>'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
コード例 #30
0
ファイル: test_format_text.py プロジェクト: usuariobkp/ckan
 def test_auto_link_after_whitespace(self):
     instr = 'go to http://somelink.com'
     exp = 'go to <a href="http://somelink.com" target="_blank" rel="nofollow">http://somelink.com</a>'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
コード例 #31
0
 def test_markdown_blank(self):
     instr = None
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert out == ''
コード例 #32
0
 def test_internal_tag_with_no_closing_quote_does_not_match(self):
     """Asserts that without an opening quote only one word is matched"""
     instr = 'tag:"test tag foobar'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert "<a href" not in out
コード例 #33
0
 def test_malformed_link_2(self):
     instr = u'<a href="http://url.com> url >'
     exp = '<a href="TAG MALFORMED" target="_blank" rel="nofollow"> url &gt;'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
コード例 #34
0
 def test_malformed_link_1(self):
     instr = u'<a href=\u201dsomelink\u201d>somelink</a>'
     exp = '<a href="TAG MALFORMED" target="_blank" rel="nofollow">somelink</a>'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
コード例 #35
0
 def test_normal_link(self):
     instr = '<http://somelink/>'
     exp = '<a href="http://somelink/" target="_blank" rel="nofollow">http://somelink/</a>'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
コード例 #36
0
 def test_internal_link(self):
     instr = 'package:test-_pkg'
     exp = '<a href="/package/test-_pkg">package:test-_pkg</a>'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
コード例 #37
0
ファイル: test_format_text.py プロジェクト: usuariobkp/ckan
 def test_internal_tag_with_no_closing_quote_does_not_match(self):
     """Asserts that without an opening quote only one word is matched"""
     instr = 'tag:"test tag foobar'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert "<a href" not in out
コード例 #38
0
ファイル: test_format_text.py プロジェクト: kindly/ckantest
 def test_markdown_blank(self):
     instr = None
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert out == ''
コード例 #39
0
ファイル: test_format_text.py プロジェクト: okfn/ckan-old
 def test_normal_link(self):
     instr = "<http:/somelink/>"
     exp = '<a href="http:/somelink/">http:/somelink/</a>'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, "\nGot: %s\nWanted: %s" % (out, exp)