def test_merge_paths_with_base_path_without_base_authority(): """Demonstrate merging with a base URI without an authority.""" base = URIReference(scheme=None, authority=None, path='/foo/bar/bogus', query=None, fragment=None) expected = '/foo/bar/relative' assert merge_paths(base, 'relative') == expected
def test_merge_paths_with_base_authority_without_path(): """Demonstrate merging with a base URI without an authority or path.""" base = URIReference(scheme=None, authority='authority', path=None, query=None, fragment=None) expected = '/relative' assert merge_paths(base, 'relative') == expected
def test_merge_paths_with_base_authority_and_path(): """Demonstrate merging with a base URI with an authority and path.""" base = URIReference( scheme=None, authority="authority", path="/foo/bar/bogus", query=None, fragment=None, ) expected = "/foo/bar/relative" assert merge_paths(base, "relative") == expected
def test_fragment_normalization(): uri = URIReference(None, "example.com", None, None, "fiz%DF").normalize() assert uri.fragment == "fiz%DF"
def test_authority_normalization(authority, expected_authority): uri = URIReference(None, authority, None, None, None).normalize() assert uri.authority == expected_authority
def test_hostname_normalization(): assert URIReference(None, "EXAMPLE.COM", None, None, None) == URIReference(None, "example.com", None, None, None)
def uris(request): to_norm, normalized = request.param return ( URIReference(None, None, to_norm, None, None), URIReference(None, None, normalized, None, None), )
def test_invalid_query_component(self): uri = URIReference(None, None, None, 'foo#bar', None) assert uri.is_valid() is False
def test_invalid_fragment_component(self): uri = URIReference(None, None, None, None, 'foo#bar') assert uri.is_valid() is False
def test_invalid_path(self): uri = URIReference(None, None, 'foo#bar', None, None) assert uri.is_valid() is False
def test_invalid_scheme(self): uri = URIReference('123', None, None, None, None) assert uri.is_valid() is False
def test_fragment_normalization(): uri = URIReference(None, 'example.com', None, None, 'fiz%DF').normalize() assert uri.fragment == 'fiz%DF'
def test_hostname_normalization(): assert (URIReference(None, 'EXAMPLE.COM', None, None, None) == URIReference(None, 'example.com', None, None, None))
def test_authority_normalization(): uri = URIReference(None, '*****@*****.**', None, None, None).normalize() assert uri.authority == '*****@*****.**'