示例#1
0
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
示例#2
0
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_)
示例#3
0
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 />'
示例#4
0
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)
示例#5
0
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()
示例#6
0
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()
示例#7
0
def test_create_protocols_bare(protocol):
    protocol_bare = chupycabra.Protocol(name=protocol)
    assert protocol_bare.__str__() == "<%s />" % protocol
示例#8
0
def test_protocol_setType():
    protocol = chupycabra.Protocol('protocol')
    protocol.setType('error')
    assert protocol.getType() == 'error'