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_serialize_multi_values(): hdr = Header(b'Via') hdr.add_value( b'SIP/2.0/UDP bigbox3.site3.atlanta.com;branch=z9hG4bK77ef4c2312983.1') hdr.add_value(b'SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bK776asdhds') assert b'Via: SIP/2.0/UDP bigbox3.site3.atlanta.com;branch=z9hG4bK77ef4c2312983.1\r\nVia: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bK776asdhds' == hdr.serialize_to_bytes( ) assert 'Via: SIP/2.0/UDP bigbox3.site3.atlanta.com;branch=z9hG4bK77ef4c2312983.1\r\nVia: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bK776asdhds' == hdr.serialize_to_string( )
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()
def test_serialize_single_value(): hdr = Header('Content-Length') hdr.add_value('10') assert b'Content-Length: 10' == hdr.serialize_to_bytes() assert 'Content-Length: 10' == hdr.serialize_to_string()