def test_protocol_setID(): """IDs need to be unique o nthe server and in the stream, but these tests do not check for that. Heck, the code doesn't now, either. """ protocol = chupycabra.Protocol('protocol') id = uuid.uuid4() protocol.setID(id) assert protocol.getID() == id
def test_protocol_swap_from_to(): protocol = chupycabra.Protocol('protocol') protocol.setFrom('*****@*****.**') protocol.setTo('*****@*****.**') to, from_ = protocol.getTo(), protocol.getFrom() protocol.setFrom(to) protocol.setTo(from_) assert (protocol.getFrom(), protocol.getTo()) == (to, from_)
def test_create_protocol_xdb(): xdb_protocol = chupycabra.Protocol('xdb', to=None, type=None, attrs=None, frm=None, payload=[], node=None) assert xdb_protocol.__str__() == '<xdb />'
def test_protocol_swap_from_to2(): protocol = chupycabra.Protocol('protocol') original_from = '*****@*****.**' original_to = '*****@*****.**' protocol.setFrom(original_from) protocol.setTo(original_to) protocol.swap_from_to() assert (protocol.getFrom(), protocol.getTo()) == (original_to, original_from)
def test_protocol_setTo_JID(): protocol = chupycabra.Protocol('protocol') full_jid_JID = chupycabra.JID('[email protected]/resourcepart') protocol.setTo(full_jid_JID) assert full_jid_JID == protocol.getTo()
def test_setTo_string(): protocol = chupycabra.Protocol('protocol') full_jid_string = '[email protected]/resourcepart' protocol.setTo(full_jid_string) assert full_jid_string == protocol.getTo()
def test_create_protocols_bare(protocol): protocol_bare = chupycabra.Protocol(name=protocol) assert protocol_bare.__str__() == "<%s />" % protocol
def test_protocol_setType(): protocol = chupycabra.Protocol('protocol') protocol.setType('error') assert protocol.getType() == 'error'