def test_protocol_mismatch(self): """ If protocol doesn't match, verify returns False. """ assert not URI_ID(u"sip:foo.com").verify(URIPattern(b"xmpp:foo.com"))
def test_dns_mismatch(self): """ If the hostname doesn't match, verify returns False. """ assert not URI_ID(u"sip:bar.com").verify(URIPattern(b"sip:foo.com"))
def test_is_only_valid_for_uri(self): """ If anything else than an URIPattern is passed to verify, return False. """ assert not URI_ID(u"sip:foo.com").verify(object())
def test_catches_missing_colon(self): """ Raise ValueError if there's no colon within a URI-ID. """ with pytest.raises(ValueError): URI_ID(u"sip;foo.com")
def test_lowercases(self): """ The protocol is lowercased so it can be compared case-insensitively. """ uri_id = URI_ID(u"sIp:foo.com") assert b"sip" == uri_id.protocol
def test_enforces_unicode(self): """ Raise TypeError if pass URI-ID is not unicode. """ with pytest.raises(TypeError): URI_ID(b"sip:foo.com")
def test_match(self): """ Accept legal matches. """ assert URI_ID(u"sip:foo.com").verify(URIPattern(b"sip:foo.com"))