def test_path_url_encoded(self): """ A path is URL encoded when necessary. """ parsed = urlparse('https://www.amazon.com/\xe2') self.assertEqual(_make_canonical_uri(parsed), "https://www.amazon.com/%E2")
def test_path_url_encoded(self): """ A path is URL encoded when necessary. """ parsed = urlparse.urlparse('https://www.amazon.com/\xe2') self.assertEqual(_make_canonical_uri(parsed), "https://www.amazon.com/%E2")
def test_path(self): """ A URL with a path has a canonical URI with the same path. """ self.assertEqual( _make_canonical_uri(urlparse('https://www.amazon.com/a/b')), "https://www.amazon.com/a/b")
def test_path_not_normalized(self): """ A URL whose path has duplicate slashes has a canonical URI with duplicated slashes. """ self.assertEqual( _make_canonical_uri(urlparse('https://www.amazon.com//a/b')), "https://www.amazon.com//a/b")
def test_empty_path(self): """ A URL with an empty path has a canonical URI with an empty path. """ self.assertEqual( _make_canonical_uri(urlparse('https://www.amazon.com/')), "https://www.amazon.com/")
def test_path(self): """ A URL with a path has a canonical URI with the same path. """ self.assertEqual( _make_canonical_uri( urlparse.urlparse('https://www.amazon.com/a/b')), "https://www.amazon.com/a/b")
def test_empty_path(self): """ A URL with an empty path has a canonical URI with an empty path. """ self.assertEqual( _make_canonical_uri(urlparse.urlparse('https://www.amazon.com/')), "https://www.amazon.com/")
def test_path_not_normalized(self): """ A URL whose path has duplicate slashes has a canonical URI with duplicated slashes. """ self.assertEqual( _make_canonical_uri( urlparse.urlparse('https://www.amazon.com//a/b')), "https://www.amazon.com//a/b")
def test_query_params_and_fragments_removed(self): """ A URL's canonical URI has that URL's query string, parameters, and fragment removed. """ parsed = urlparse('https://www.amazon.com//a/b') parsed = parsed._replace(query="query=1", params="params", fragment="fragment") self.assertEqual(_make_canonical_uri(parsed), "https://www.amazon.com//a/b")
def test_query_params_and_fragments_removed(self): """ A URL's canonical URI has that URL's query string, parameters, and fragment removed. """ parsed = urlparse.urlparse('https://www.amazon.com//a/b') parsed = parsed._replace(query="query=1", params="params", fragment="fragment") self.assertEqual(_make_canonical_uri(parsed), "https://www.amazon.com//a/b")