added tests for host matching and param splitting

git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@2115 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
calvin 2005-01-10 20:35:01 +00:00
parent b1d1af52a7
commit c1a25e2e8b

View file

@ -78,6 +78,9 @@ class TestUrl (unittest.TestCase):
url = "http://example.com/a*+-();b"
nurl = url
self.assertEqual(url_norm(url), nurl)
url = "http://www.company.com/path/doc.html?url=/path2/doc2.html?foo=bar"
nurl = url
self.assertEqual(url_norm(url), nurl)
def test_norm_case_sensitivity (self):
"""test url norm case sensitivity"""
@ -371,6 +374,28 @@ class TestUrl (unittest.TestCase):
self.assert_(not is_idn)
self.assert_(not encurl)
def test_match_host (self):
"""test host matching"""
self.assert_(not linkcheck.url.match_host("localhost", [".localhost"]))
self.assert_(linkcheck.url.match_host("a.localhost", [".localhost"]))
self.assert_(linkcheck.url.match_host("localhost", ["localhost"]))
def test_splitparam (self):
"""path parameter split test"""
p = [
("", ("", "")),
("/", ("/", "")),
("a", ("a", "")),
("a;", ("a", "")),
("a/b;c/d;e", ("a/b;c/d", "e")),
]
for x in p:
self._splitparam(x)
def _splitparam (self, x):
self.assertEqual(linkcheck.url.splitparams(x[0]), (x[1][0], x[1][1]))
def test_suite ():
"""build and return a TestSuite"""
suite = unittest.TestSuite()