# HG changeset patch # User Mads Kiilerich # Date 1473115878 -7200 # Node ID 7df89ff2de80ad4451654643be4d27300d5e065b # Parent d3957c90499bdaef0f593f0e333f4f57df2eebea helpers: improve test coverage of urlify_text diff -r d3957c90499b -r 7df89ff2de80 kallithea/tests/other/test_libs.py --- a/kallithea/tests/other/test_libs.py Tue Sep 06 00:51:18 2016 +0200 +++ b/kallithea/tests/other/test_libs.py Tue Sep 06 00:51:18 2016 +0200 @@ -290,29 +290,29 @@ ("", ""), ("git-svn-id: https://svn.apache.org/repos/asf/libcloud/trunk@1441655 13f79535-47bb-0310-9956-ffa450edef68", - "git-svn-id: https://svn.apache.org/repos/asf/libcloud/trunk@1441655 13f79535-47bb-0310-9956-ffa450edef68"), + """git-svn-id: https://svn.apache.org/repos/asf/libcloud/trunk@1441655 13f79535-47bb-0310-9956-ffa450edef68"""), ("from rev 000000000000", - "from rev url[000000000000]"), + """from rev url[000000000000]"""), ("from rev 000000000000123123 also rev 000000000000", - "from rev url[000000000000123123] also rev url[000000000000]"), + """from rev url[000000000000123123] also rev url[000000000000]"""), ("this should-000 00", - "this should-000 00"), + """this should-000 00"""), ("longtextffffffffff rev 123123123123", - "longtextffffffffff rev url[123123123123]"), + """longtextffffffffff rev url[123123123123]"""), ("rev ffffffffffffffffffffffffffffffffffffffffffffffffff", - "rev ffffffffffffffffffffffffffffffffffffffffffffffffff"), + """rev ffffffffffffffffffffffffffffffffffffffffffffffffff"""), ("ffffffffffff some text traalaa", - "url[ffffffffffff] some text traalaa"), + """url[ffffffffffff] some text traalaa"""), ("""Multi line 123123123123 some text 123123123123 sometimes ! """, - """Multi line - url[123123123123] - some text url[123123123123] - sometimes ! - """) + """Multi line\n""" + """ url[123123123123]\n""" + """ some text url[123123123123]\n""" + """ sometimes !\n""" + """ """), ]) def test_urlify_changesets(self, sample, expected): def fake_url(self, *args, **kwargs): @@ -329,27 +329,37 @@ "", ""), ("https://svn.apache.org/repos", - "url[https://svn.apache.org/repos]", + """url[https://svn.apache.org/repos]""", "https://svn.apache.org/repos"), ("http://svn.apache.org/repos", - "url[http://svn.apache.org/repos]", + """url[http://svn.apache.org/repos]""", "http://svn.apache.org/repos"), ("from rev a also rev http://google.com", - "from rev a also rev url[http://google.com]", + """from rev a also rev url[http://google.com]""", "http://google.com"), - ("""Multi line + ("http://imgur.com/foo.gif inline http://imgur.com/foo.gif ending http://imgur.com/foo.gif", + """url[http://imgur.com/foo.gif] inline url[http://imgur.com/foo.gif] ending url[http://imgur.com/foo.gif]""", + "http://imgur.com/foo.gif"), + ("""Multi line https://foo.bar.example.com some text lalala""", - """Multi line - url[https://foo.bar.example.com] - some text lalala""", - "https://foo.bar.example.com") + """Multi line\n""" + """ url[https://foo.bar.example.com]\n""" + """ some text lalala""", + "https://foo.bar.example.com"), + ("@mention @someone", + """@mention @someone""", + ""), + ("deadbeefcafe 123412341234", + """deadbeefcafe 123412341234""", + ""), + # tags are covered by test_tag_extractor ]) def test_urlify_test(self, sample, expected, url_): from kallithea.lib.helpers import urlify_text expected = self._quick_url(expected, tmpl="""%s""", url_=url_) - assert urlify_text(sample) == expected + assert urlify_text(sample, stylize=True) == expected @parametrize('test,expected', [ ("", None),