def test_topmost_via(): hdr = Header('Via') hdr.add_values([ "SIP/2.0/UDP bigbox3.site3.atlanta.com;branch=z9hG4bK77ef4c2312983.1", "SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bK776asdhds" ]) via = ViaHeader.topmost_via(hdr) assert SentProtocol('SIP', '2.0', Transport('UDP')) == via.sent_protocol assert 'bigbox3.site3.atlanta.com' == via.sent_by.host assert 5060 == via.sent_by.port
def test_topmost_via_ipport(): hdr = Header('via') hdr.add_values([ "SIP/2.0/TCP 192.168.1.1:5090;branch=z9hG4bK77ef4c2312983.1", "SIP/2.0/UDP bigbox3.site3.atlanta.com;branch=z9hG4bK77ef4c2312983.1", "SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bK776asdhds" ]) via = ViaHeader.topmost_via(hdr) assert SentProtocol('SIP', '2.0', Transport('TCP')) == via.sent_protocol assert ipaddress.IPv4Address('192.168.1.1') == via.sent_by.host assert 5090 == via.sent_by.port
def test_comma_split_values(): h1 = Header(b'route') h1.add_values([ b"<sip:[email protected]>", b"<sip:[email protected]>", b"<sip:[email protected]>" ]) h2 = Header(b'route') h2.add_values([ b"<sip:[email protected]>, <sip:[email protected]>", b"<sip:[email protected]>" ]) h3 = Header(b'route') h3.add_values([ b'<sip:[email protected]>, <sip:[email protected]>, <sip:[email protected]>' ]) assert h1 == h2 assert h1 == h3
def test_allow_empty(): h = Header(b'Allow') h.add_values([]) assert b'A: B' == h.serialize_to_bytes(append_value=b'A: B')
def test_contact(): h = Header(b'Contact') h.add_values([b"sip:a@b", b"sip:a@c"]) assert b'Contact: sip:a@b\r\nContact: sip:a@c' == h.serialize_to_bytes()
def test_allow_compact(): h = Header(b'Allow') h.add_values([b'ACK', b'INVITE', b'OPTIONS']) assert b'Allow: ACK, INVITE, OPTIONS' == h.serialize_to_bytes()