Example #1
0
 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"))
Example #2
0
 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"))
Example #3
0
 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())
Example #4
0
 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")
Example #5
0
 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
Example #6
0
 def test_enforces_unicode(self):
     """
     Raise TypeError if pass URI-ID is not unicode.
     """
     with pytest.raises(TypeError):
         URI_ID(b"sip:foo.com")
Example #7
0
 def test_match(self):
     """
     Accept legal matches.
     """
     assert URI_ID(u"sip:foo.com").verify(URIPattern(b"sip:foo.com"))