def test_remove_fragment(self): self.assertEquals("http://google.com", canonicalize("http://google.com#thisisatest")) self.assertEquals( "http://google.com/test/testing", canonicalize("http://google.com/test/testing#boompow"))
def test_remove_empty_query(self): self.assertEquals("http://google.com", canonicalize("http://google.com?")) self.assertNotEquals("http://google.com", canonicalize("http://google.com?test=blah"))
def test_sort_query_parameters(self): self.assertEquals("http://google.com?a=b&c=d", canonicalize("http://google.com?c=d&a=b")) self.assertEquals( "http://google.com?password=******&username=test", canonicalize("http://google.com?username=test&password=******"))
def test_lower_scheme_domain(self): self.assertEquals("http://google.com", canonicalize("HtTP://GooGlE.COm")) self.assertEquals("http://google.com/Bob", canonicalize("HtTP://GooglE.com/Bob"))
def test_remove_double_slashes(self): self.assertEquals("http://google.com/test", canonicalize("http://google.com//test")) self.assertEquals("http://google.com/test/blah/ick/", canonicalize("http://google.com/test//blah//ick//"))
def _less(url1, url2): return canonicalize(url1) < canonicalize(url2)
def _greater(url1, url2): return canonicalize(url1) > canonicalize(url2)
def _equals(url1, url2): return canonicalize(url1) == canonicalize(url2)
def test_remove_fragment(self): self.assertEquals("http://google.com", canonicalize("http://google.com#thisisatest")) self.assertEquals("http://google.com/test/testing", canonicalize("http://google.com/test/testing#boompow"))
def test_sort_query_parameters(self): self.assertEquals("http://google.com?a=b&c=d", canonicalize("http://google.com?c=d&a=b")) self.assertEquals("http://google.com?password=******&username=test", canonicalize("http://google.com?username=test&password=******"))