diff options
author | Xavier Claessens <xavier.claessens@collabora.co.uk> | 2013-09-20 16:46:27 -0400 |
---|---|---|
committer | Xavier Claessens <xavier.claessens@collabora.co.uk> | 2013-09-24 14:45:10 -0400 |
commit | 13057873b29b66d03cabbcafb35b2aaa256a15c9 (patch) | |
tree | 1c0664379b93f41318264e206ce20c8af4cfc236 | |
parent | cee5db613ee8d491719889de835849e36a826ca2 (diff) | |
download | telepathy-salut-13057873b29b66d03cabbcafb35b2aaa256a15c9.tar.gz |
Tests: Use constants everywhere
-rw-r--r-- | tests/twisted/avahi/caps-file-transfer.py | 20 | ||||
-rw-r--r-- | tests/twisted/avahi/ichat-composing.py | 7 | ||||
-rw-r--r-- | tests/twisted/avahi/ichat-incoming-msg.py | 9 | ||||
-rw-r--r-- | tests/twisted/avahi/request-im.py | 40 | ||||
-rw-r--r-- | tests/twisted/avahi/request-muc.py | 42 | ||||
-rw-r--r-- | tests/twisted/avahi/roomlist.py | 24 | ||||
-rw-r--r-- | tests/twisted/avahi/text-channel.py | 13 | ||||
-rw-r--r-- | tests/twisted/avahi/tubes/request-muc-tubes.py | 54 | ||||
-rw-r--r-- | tests/twisted/avahi/tubes/two-muc-stream-tubes.py | 46 |
9 files changed, 121 insertions, 134 deletions
diff --git a/tests/twisted/avahi/caps-file-transfer.py b/tests/twisted/avahi/caps-file-transfer.py index 4a630d16..627d43cb 100644 --- a/tests/twisted/avahi/caps-file-transfer.py +++ b/tests/twisted/avahi/caps-file-transfer.py @@ -27,7 +27,7 @@ from servicetest import EventPattern, assertContains, assertDoesNotContain from saluttest import exec_test, make_result_iq from xmppstream import setup_stream_listener import ns -from constants import * +import constants as cs from caps_helper import compute_caps_hash, ft_fixed_properties, \ ft_allowed_properties, ft_allowed_properties_with_metadata @@ -99,8 +99,8 @@ def caps_contain(event, cap): def test_ft_caps_from_contact(q, bus, conn, client): - conn_caps_iface = dbus.Interface(conn, CONN_IFACE_CONTACT_CAPS) - conn_contacts_iface = dbus.Interface(conn, CONN_IFACE_CONTACTS) + conn_caps_iface = dbus.Interface(conn, cs.CONN_IFACE_CONTACT_CAPS) + conn_contacts_iface = dbus.Interface(conn, cs.CONN_IFACE_CONTACTS) # send presence with FT capa ver = compute_caps_hash([], [ns.IQ_OOB], {}) @@ -122,7 +122,7 @@ def test_ft_caps_from_contact(q, bus, conn, client): assert query_node.attributes['node'] == \ client + '#' + ver, (query_node.attributes['node'], client, ver) - contact_handle = conn.RequestHandles(HT_CONTACT, [contact_name])[0] + contact_handle = conn.RequestHandles(cs.HT_CONTACT, [contact_name])[0] # send good reply result = make_result_iq(event.stanza) @@ -144,13 +144,13 @@ def test_ft_caps_from_contact(q, bus, conn, client): # check the Contacts interface give the same caps caps_via_contacts_iface = conn_contacts_iface.GetContactAttributes( - [contact_handle], [CONN_IFACE_CONTACT_CAPS], False) \ - [contact_handle][CONN_IFACE_CONTACT_CAPS + '/capabilities'] + [contact_handle], [cs.CONN_IFACE_CONTACT_CAPS], False) \ + [contact_handle][cs.CONN_IFACE_CONTACT_CAPS + '/capabilities'] assert caps_via_contacts_iface == caps, caps_via_contacts_iface # check if Salut announces the OOB capa self_handle = conn.GetSelfHandle() - self_handle_name = conn.InspectHandles(HT_CONTACT, [self_handle])[0] + self_handle_name = conn.InspectHandles(cs.HT_CONTACT, [self_handle])[0] AvahiListener(q).listen_for_service("_presence._tcp") e = q.expect('service-added', name = self_handle_name, @@ -180,7 +180,7 @@ def test_ft_caps_from_contact(q, bus, conn, client): assert query_node.attributes['node'] == \ client + '#' + ver, (query_node.attributes['node'], client, ver) - contact_handle = conn.RequestHandles(HT_CONTACT, [contact_name])[0] + contact_handle = conn.RequestHandles(cs.HT_CONTACT, [contact_name])[0] # send good reply result = make_result_iq(event.stanza) @@ -203,7 +203,7 @@ def test_ft_caps_from_contact(q, bus, conn, client): # no capabilites announced (assume FT is supported to insure interop) txt_record = { "txtvers": "1", "status": "avail"} contact_name = "test-caps-ft-no-capa2@" + get_host_name() - contact_handle = conn.RequestHandles(HT_CONTACT, [contact_name])[0] + contact_handle = conn.RequestHandles(cs.HT_CONTACT, [contact_name])[0] listener, port = setup_stream_listener(q, contact_name) announcer = AvahiAnnouncer(contact_name, "_presence._tcp", port, txt_record) @@ -228,7 +228,7 @@ def test(q, bus, conn): # check our own capabilities self_handle = conn.GetSelfHandle() - conn_caps_iface = dbus.Interface(conn, CONN_IFACE_CONTACT_CAPS) + conn_caps_iface = dbus.Interface(conn, cs.CONN_IFACE_CONTACT_CAPS) caps = conn_caps_iface.GetContactCapabilities([self_handle])[self_handle] assertContains(ft_metadata_caps, caps) diff --git a/tests/twisted/avahi/ichat-composing.py b/tests/twisted/avahi/ichat-composing.py index db81e521..b47ad898 100644 --- a/tests/twisted/avahi/ichat-composing.py +++ b/tests/twisted/avahi/ichat-composing.py @@ -12,9 +12,8 @@ from twisted.words.xish import xpath, domish import time import dbus -CHANNEL_TYPE_TEXT = "org.freedesktop.Telepathy.Channel.Type.Text" -HT_CONTACT = 1 -HT_CONTACT_LIST = 3 +import constants as cs + OUTGOING_MESSAGE = "This is a message" def test(q, bus, conn): @@ -30,7 +29,7 @@ def test(q, bus, conn): handle = wait_for_contact_in_publish(q, bus, conn, contact_name) self_handle = conn.GetSelfHandle() - self_handle_name = conn.InspectHandles(HT_CONTACT, [self_handle])[0] + self_handle_name = conn.InspectHandles(cs.HT_CONTACT, [self_handle])[0] AvahiListener(q).listen_for_service("_presence._tcp") e = q.expect('service-added', name = self_handle_name, diff --git a/tests/twisted/avahi/ichat-incoming-msg.py b/tests/twisted/avahi/ichat-incoming-msg.py index 6a16f069..5f9027fa 100644 --- a/tests/twisted/avahi/ichat-incoming-msg.py +++ b/tests/twisted/avahi/ichat-incoming-msg.py @@ -12,10 +12,7 @@ from twisted.words.xish import xpath, domish import time import dbus -CHANNEL_TYPE_TEXT = "org.freedesktop.Telepathy.Channel.Type.Text" -HT_CONTACT = 1 -HT_CONTACT_LIST = 3 -TEXT_MESSAGE_TYPE_NORMAL = dbus.UInt32(0) +import constants as cs INCOMING_MESSAGE = "Test 123" @@ -25,7 +22,7 @@ def test(q, bus, conn): basic_txt = { "txtvers": "1", "status": "avail" } self_handle = conn.GetSelfHandle() - self_handle_name = conn.InspectHandles(HT_CONTACT, [self_handle])[0] + self_handle_name = conn.InspectHandles(cs.HT_CONTACT, [self_handle])[0] contact_name = "test-ichat-incoming-msg@" + get_host_name() listener, port = setup_stream_listener(q, contact_name) @@ -58,7 +55,7 @@ def test(q, bus, conn): e = q.expect('dbus-signal', signal='Received') assert e.args[2] == handle - assert e.args[3] == TEXT_MESSAGE_TYPE_NORMAL + assert e.args[3] == cs.MT_NORMAL assert e.args[5] == "hi" if __name__ == '__main__': diff --git a/tests/twisted/avahi/request-im.py b/tests/twisted/avahi/request-im.py index a61a3684..97fc3402 100644 --- a/tests/twisted/avahi/request-im.py +++ b/tests/twisted/avahi/request-im.py @@ -12,9 +12,7 @@ from servicetest import call_async, EventPattern, \ from avahitest import get_host_name, AvahiAnnouncer from xmppstream import setup_stream_listener -CHANNEL_TYPE_TEXT = 'org.freedesktop.Telepathy.Channel.Type.Text' - -HT_CONTACT = 1 +import constants as cs def test(q, bus, conn): self_name = 'testsuite' + '@' + get_host_name() @@ -39,8 +37,8 @@ def test(q, bus, conn): tp_name_prefix + '.Connection.Interface.Requests', dbus_interface='org.freedesktop.DBus.Properties') assert ({tp_name_prefix + '.Channel.ChannelType': - CHANNEL_TYPE_TEXT, - tp_name_prefix + '.Channel.TargetHandleType': HT_CONTACT, + cs.CHANNEL_TYPE_TEXT, + tp_name_prefix + '.Channel.TargetHandleType': cs.HT_CONTACT, }, [tp_name_prefix + '.Channel.TargetHandle', tp_name_prefix + '.Channel.TargetID'], @@ -48,8 +46,8 @@ def test(q, bus, conn): properties['RequestableChannelClasses'] # request a muc channel using the old API - handle = conn.RequestHandles(HT_CONTACT, [contact_name])[0] - call_async(q, conn, 'RequestChannel', CHANNEL_TYPE_TEXT, HT_CONTACT, handle, True) + handle = conn.RequestHandles(cs.HT_CONTACT, [contact_name])[0] + call_async(q, conn, 'RequestChannel', cs.CHANNEL_TYPE_TEXT, cs.HT_CONTACT, handle, True) ret, old_sig, new_sig = q.expect_many( EventPattern('dbus-return', method='RequestChannel'), @@ -64,8 +62,8 @@ def test(q, bus, conn): props = new_sig.args[0][0][1] assert props[tp_name_prefix + '.Channel.ChannelType'] ==\ - CHANNEL_TYPE_TEXT - assert props[tp_name_prefix + '.Channel.TargetHandleType'] == HT_CONTACT + cs.CHANNEL_TYPE_TEXT + assert props[tp_name_prefix + '.Channel.TargetHandleType'] == cs.HT_CONTACT assert props[tp_name_prefix + '.Channel.TargetHandle'] == handle assert props[tp_name_prefix + '.Channel.TargetID'] == contact_name assert props[tp_name_prefix + '.Channel.Requested'] == True @@ -75,8 +73,8 @@ def test(q, bus, conn): == self_name assert old_sig.args[0] == path1 - assert old_sig.args[1] == CHANNEL_TYPE_TEXT - assert old_sig.args[2] == HT_CONTACT # handle type + assert old_sig.args[1] == cs.CHANNEL_TYPE_TEXT + assert old_sig.args[2] == cs.HT_CONTACT # handle type assert old_sig.args[3] == handle # handle # Exercise basic Channel Properties from spec 0.17.7 @@ -86,10 +84,10 @@ def test(q, bus, conn): assert channel_props.get('TargetHandle') == handle,\ channel_props.get('TargetHandle') assert channel_props['TargetID'] == contact_name, channel_props - assert channel_props.get('TargetHandleType') == HT_CONTACT,\ + assert channel_props.get('TargetHandleType') == cs.HT_CONTACT,\ channel_props.get('TargetHandleType') assert channel_props.get('ChannelType') == \ - CHANNEL_TYPE_TEXT, channel_props.get('ChannelType') + cs.CHANNEL_TYPE_TEXT, channel_props.get('ChannelType') assert channel_props['Requested'] == True assert channel_props['InitiatorID'] == self_name assert channel_props['InitiatorHandle'] == conn.GetSelfHandle() @@ -105,8 +103,8 @@ def test(q, bus, conn): # create muc channel using new API call_async(q, requestotron, 'CreateChannel', { tp_name_prefix + '.Channel.ChannelType': - CHANNEL_TYPE_TEXT, - tp_name_prefix + '.Channel.TargetHandleType': HT_CONTACT, + cs.CHANNEL_TYPE_TEXT, + tp_name_prefix + '.Channel.TargetHandleType': cs.HT_CONTACT, tp_name_prefix + '.Channel.TargetID': contact_name, }) @@ -120,8 +118,8 @@ def test(q, bus, conn): props = ret.value[1] assert props[tp_name_prefix + '.Channel.ChannelType'] ==\ - CHANNEL_TYPE_TEXT - assert props[tp_name_prefix + '.Channel.TargetHandleType'] == HT_CONTACT + cs.CHANNEL_TYPE_TEXT + assert props[tp_name_prefix + '.Channel.TargetHandleType'] == cs.HT_CONTACT assert props[tp_name_prefix + '.Channel.TargetHandle'] == handle assert props[tp_name_prefix + '.Channel.TargetID'] == contact_name assert props[tp_name_prefix + '.Channel.Requested'] == True @@ -134,16 +132,16 @@ def test(q, bus, conn): assert new_sig.args[0][0][1] == props assert old_sig.args[0] == path2 - assert old_sig.args[1] == CHANNEL_TYPE_TEXT - assert old_sig.args[2] == HT_CONTACT # handle type + assert old_sig.args[1] == cs.CHANNEL_TYPE_TEXT + assert old_sig.args[2] == cs.HT_CONTACT # handle type assert old_sig.args[3] == handle # handle assert old_sig.args[4] == True # suppress handler # ensure roomlist channel yours, ensured_path, ensured_props = requestotron.EnsureChannel( { tp_name_prefix + '.Channel.ChannelType': - CHANNEL_TYPE_TEXT, - tp_name_prefix + '.Channel.TargetHandleType': HT_CONTACT, + cs.CHANNEL_TYPE_TEXT, + tp_name_prefix + '.Channel.TargetHandleType': cs.HT_CONTACT, tp_name_prefix + '.Channel.TargetHandle': handle, }) diff --git a/tests/twisted/avahi/request-muc.py b/tests/twisted/avahi/request-muc.py index 73497d3d..d3ad76cd 100644 --- a/tests/twisted/avahi/request-muc.py +++ b/tests/twisted/avahi/request-muc.py @@ -12,9 +12,7 @@ from saluttest import exec_test, wait_for_contact_list from servicetest import call_async, EventPattern, \ tp_name_prefix, tp_path_prefix, make_channel_proxy -CHANNEL_TYPE_TEXT = 'org.freedesktop.Telepathy.Channel.Type.Text' - -HT_ROOM = 2 +import constants as cs def test(q, bus, conn): self_name = 'testsuite' + '@' + avahitest.get_host_name() @@ -32,8 +30,8 @@ def test(q, bus, conn): tp_name_prefix + '.Connection.Interface.Requests', dbus_interface='org.freedesktop.DBus.Properties') assert ({tp_name_prefix + '.Channel.ChannelType': - CHANNEL_TYPE_TEXT, - tp_name_prefix + '.Channel.TargetHandleType': HT_ROOM, + cs.CHANNEL_TYPE_TEXT, + tp_name_prefix + '.Channel.TargetHandleType': cs.HT_ROOM, }, [tp_name_prefix + '.Channel.TargetHandle', tp_name_prefix + '.Channel.TargetID'], @@ -41,8 +39,8 @@ def test(q, bus, conn): properties['RequestableChannelClasses'] # request a muc channel using the old API - handle = conn.RequestHandles(HT_ROOM, ['my-first-room'])[0] - call_async(q, conn, 'RequestChannel', CHANNEL_TYPE_TEXT, HT_ROOM, handle, True) + handle = conn.RequestHandles(cs.HT_ROOM, ['my-first-room'])[0] + call_async(q, conn, 'RequestChannel', cs.CHANNEL_TYPE_TEXT, cs.HT_ROOM, handle, True) ret, old_sig, new_sig = q.expect_many( EventPattern('dbus-return', method='RequestChannel'), @@ -57,8 +55,8 @@ def test(q, bus, conn): props = new_sig.args[0][0][1] assert props[tp_name_prefix + '.Channel.ChannelType'] ==\ - CHANNEL_TYPE_TEXT - assert props[tp_name_prefix + '.Channel.TargetHandleType'] == HT_ROOM + cs.CHANNEL_TYPE_TEXT + assert props[tp_name_prefix + '.Channel.TargetHandleType'] == cs.HT_ROOM assert props[tp_name_prefix + '.Channel.TargetHandle'] == handle assert props[tp_name_prefix + '.Channel.TargetID'] == 'my-first-room' assert props[tp_name_prefix + '.Channel.Requested'] == True @@ -68,8 +66,8 @@ def test(q, bus, conn): == self_name assert old_sig.args[0] == path1 - assert old_sig.args[1] == CHANNEL_TYPE_TEXT - assert old_sig.args[2] == HT_ROOM # handle type + assert old_sig.args[1] == cs.CHANNEL_TYPE_TEXT + assert old_sig.args[2] == cs.HT_ROOM # handle type assert old_sig.args[3] == handle # handle # Exercise basic Channel Properties from spec 0.17.7 @@ -79,10 +77,10 @@ def test(q, bus, conn): assert channel_props.get('TargetHandle') == handle,\ channel_props.get('TargetHandle') assert channel_props['TargetID'] == 'my-first-room', channel_props - assert channel_props.get('TargetHandleType') == HT_ROOM,\ + assert channel_props.get('TargetHandleType') == cs.HT_ROOM,\ channel_props.get('TargetHandleType') assert channel_props.get('ChannelType') == \ - CHANNEL_TYPE_TEXT, channel_props.get('ChannelType') + cs.CHANNEL_TYPE_TEXT, channel_props.get('ChannelType') assert channel_props['Requested'] == True assert channel_props['InitiatorID'] == self_name assert channel_props['InitiatorHandle'] == conn.GetSelfHandle() @@ -93,8 +91,8 @@ def test(q, bus, conn): # create muc channel using new API call_async(q, requestotron, 'CreateChannel', { tp_name_prefix + '.Channel.ChannelType': - CHANNEL_TYPE_TEXT, - tp_name_prefix + '.Channel.TargetHandleType': HT_ROOM, + cs.CHANNEL_TYPE_TEXT, + tp_name_prefix + '.Channel.TargetHandleType': cs.HT_ROOM, tp_name_prefix + '.Channel.TargetID': 'my-second-room', }) @@ -106,12 +104,12 @@ def test(q, bus, conn): path2 = ret.value[0] chan = make_channel_proxy(conn, path2, "Channel") - handle = conn.RequestHandles(HT_ROOM, ['my-second-room'])[0] + handle = conn.RequestHandles(cs.HT_ROOM, ['my-second-room'])[0] props = ret.value[1] assert props[tp_name_prefix + '.Channel.ChannelType'] ==\ - CHANNEL_TYPE_TEXT - assert props[tp_name_prefix + '.Channel.TargetHandleType'] == HT_ROOM + cs.CHANNEL_TYPE_TEXT + assert props[tp_name_prefix + '.Channel.TargetHandleType'] == cs.HT_ROOM assert props[tp_name_prefix + '.Channel.TargetHandle'] == handle assert props[tp_name_prefix + '.Channel.TargetID'] == 'my-second-room' assert props[tp_name_prefix + '.Channel.Requested'] == True @@ -124,16 +122,16 @@ def test(q, bus, conn): assert new_sig.args[0][0][1] == props assert old_sig.args[0] == path2 - assert old_sig.args[1] == CHANNEL_TYPE_TEXT - assert old_sig.args[2] == HT_ROOM # handle type + assert old_sig.args[1] == cs.CHANNEL_TYPE_TEXT + assert old_sig.args[2] == cs.HT_ROOM # handle type assert old_sig.args[3] == handle # handle assert old_sig.args[4] == True # suppress handler # ensure roomlist channel yours, ensured_path, ensured_props = ret.value = requestotron.EnsureChannel( { tp_name_prefix + '.Channel.ChannelType': - CHANNEL_TYPE_TEXT, - tp_name_prefix + '.Channel.TargetHandleType': HT_ROOM, + cs.CHANNEL_TYPE_TEXT, + tp_name_prefix + '.Channel.TargetHandleType': cs.HT_ROOM, tp_name_prefix + '.Channel.TargetHandle': handle, }) diff --git a/tests/twisted/avahi/roomlist.py b/tests/twisted/avahi/roomlist.py index 01e32da7..5930fdb6 100644 --- a/tests/twisted/avahi/roomlist.py +++ b/tests/twisted/avahi/roomlist.py @@ -13,8 +13,6 @@ from servicetest import call_async, EventPattern, \ tp_name_prefix, tp_path_prefix, wrap_channel import constants as cs -CHANNEL_TYPE_ROOMLIST = 'org.freedesktop.Telepathy.Channel.Type.RoomList' - def test(q, bus, conn): self_name = 'testsuite' + '@' + avahitest.get_host_name() @@ -31,7 +29,7 @@ def test(q, bus, conn): tp_name_prefix + '.Connection.Interface.Requests', dbus_interface='org.freedesktop.DBus.Properties') assert ({tp_name_prefix + '.Channel.ChannelType': - CHANNEL_TYPE_ROOMLIST, + cs.CHANNEL_TYPE_ROOM_LIST, tp_name_prefix + '.Channel.TargetHandleType': 0, }, [], @@ -39,7 +37,7 @@ def test(q, bus, conn): properties['RequestableChannelClasses'] # request a roomlist channel using the old API - call_async(q, conn, 'RequestChannel', CHANNEL_TYPE_ROOMLIST, 0, 0, True) + call_async(q, conn, 'RequestChannel', cs.CHANNEL_TYPE_ROOMLIST, 0, 0, True) ret, old_sig, new_sig = q.expect_many( EventPattern('dbus-return', method='RequestChannel'), @@ -54,7 +52,7 @@ def test(q, bus, conn): props = new_sig.args[0][0][1] assert props[tp_name_prefix + '.Channel.ChannelType'] ==\ - CHANNEL_TYPE_ROOMLIST + cs.CHANNEL_TYPE_ROOMLIST assert props[tp_name_prefix + '.Channel.TargetHandleType'] == 0 assert props[tp_name_prefix + '.Channel.TargetHandle'] == 0 assert props[tp_name_prefix + '.Channel.TargetID'] == '' @@ -66,7 +64,7 @@ def test(q, bus, conn): assert props[tp_name_prefix + '.Channel.Type.RoomList.Server'] == '' assert old_sig.args[0] == path1 - assert old_sig.args[1] == CHANNEL_TYPE_ROOMLIST + assert old_sig.args[1] == cs.CHANNEL_TYPE_ROOMLIST assert old_sig.args[2] == 0 # handle type assert old_sig.args[3] == 0 # handle assert old_sig.args[4] == 1 # suppress handler @@ -81,13 +79,13 @@ def test(q, bus, conn): assert channel_props.get('TargetHandleType') == 0,\ channel_props.get('TargetHandleType') assert channel_props.get('ChannelType') == \ - CHANNEL_TYPE_ROOMLIST, channel_props.get('ChannelType') + cs.CHANNEL_TYPE_ROOMLIST, channel_props.get('ChannelType') assert channel_props['Requested'] == True assert channel_props['InitiatorID'] == self_name assert channel_props['InitiatorHandle'] == conn.GetSelfHandle() assert chan.Get( - CHANNEL_TYPE_ROOMLIST, 'Server', + cs.CHANNEL_TYPE_ROOMLIST, 'Server', dbus_interface='org.freedesktop.DBus.Properties') == '' # list rooms @@ -110,7 +108,7 @@ def test(q, bus, conn): # create roomlist channel using new API call_async(q, requestotron, 'CreateChannel', { tp_name_prefix + '.Channel.ChannelType': - CHANNEL_TYPE_ROOMLIST, + cs.CHANNEL_TYPE_ROOM_LIST, tp_name_prefix + '.Channel.TargetHandleType': 0, }) @@ -124,7 +122,7 @@ def test(q, bus, conn): props = ret.value[1] assert props[tp_name_prefix + '.Channel.ChannelType'] ==\ - CHANNEL_TYPE_ROOMLIST + cs.CHANNEL_TYPE_ROOM_LIST assert props[tp_name_prefix + '.Channel.TargetHandleType'] == 0 assert props[tp_name_prefix + '.Channel.TargetHandle'] == 0 assert props[tp_name_prefix + '.Channel.TargetID'] == '' @@ -139,17 +137,17 @@ def test(q, bus, conn): assert new_sig.args[0][0][1] == props assert old_sig.args[0] == path2 - assert old_sig.args[1] == CHANNEL_TYPE_ROOMLIST + assert old_sig.args[1] == cs.CHANNEL_TYPE_ROOM_LIST assert old_sig.args[2] == 0 # handle type assert old_sig.args[3] == 0 # handle assert old_sig.args[4] == 1 # suppress handler - assert chan2.Properties.Get(CHANNEL_TYPE_ROOMLIST, 'Server') == '' + assert chan2.Properties.Get(cs.CHANNEL_TYPE_ROOM_LIST, 'Server') == '' # ensure roomlist channel yours, ensured_path, ensured_props = requestotron.EnsureChannel( { tp_name_prefix + '.Channel.ChannelType': - CHANNEL_TYPE_ROOMLIST, + cs.CHANNEL_TYPE_ROOM_LIST, tp_name_prefix + '.Channel.TargetHandleType': 0, }) diff --git a/tests/twisted/avahi/text-channel.py b/tests/twisted/avahi/text-channel.py index 68970cac..7ce5adb8 100644 --- a/tests/twisted/avahi/text-channel.py +++ b/tests/twisted/avahi/text-channel.py @@ -12,10 +12,7 @@ from twisted.words.xish import xpath, domish import time import dbus -CHANNEL_TYPE_TEXT = "org.freedesktop.Telepathy.Channel.Type.Text" -HT_CONTACT = 1 -HT_CONTACT_LIST = 3 -TEXT_MESSAGE_TYPE_NORMAL = dbus.UInt32(0) +import constants as cs INCOMING_MESSAGE = "Test 123" OUTGOING_MESSAGE = "Test 321" @@ -32,10 +29,10 @@ def test(q, bus, conn): handle = wait_for_contact_in_publish(q, bus, conn, contact_name) - t = conn.RequestChannel(CHANNEL_TYPE_TEXT, HT_CONTACT, handle, + t = conn.RequestChannel(cs.CHANNEL_TYPE_TEXT, cs.HT_CONTACT, handle, True) text_channel = make_channel_proxy(conn, t, "Channel.Type.Text") - text_channel.Send(TEXT_MESSAGE_TYPE_NORMAL, INCOMING_MESSAGE) + text_channel.Send(cs.MT_NORMAL, INCOMING_MESSAGE) e = q.expect('incoming-connection', listener = listener) incoming = e.connection @@ -50,7 +47,7 @@ def test(q, bus, conn): # Now send a message to salut self_handle = conn.GetSelfHandle() - self_handle_name = conn.InspectHandles(HT_CONTACT, [self_handle])[0] + self_handle_name = conn.InspectHandles(cs.HT_CONTACT, [self_handle])[0] AvahiListener(q).listen_for_service("_presence._tcp") @@ -79,7 +76,7 @@ def test(q, bus, conn): e = q.expect('dbus-signal', signal='Received') assert e.args[2] == handle - assert e.args[3] == TEXT_MESSAGE_TYPE_NORMAL + assert e.args[3] == cs.MT_NORMAL assert e.args[5] == OUTGOING_MESSAGE diff --git a/tests/twisted/avahi/tubes/request-muc-tubes.py b/tests/twisted/avahi/tubes/request-muc-tubes.py index 8608fa0a..b57ae98e 100644 --- a/tests/twisted/avahi/tubes/request-muc-tubes.py +++ b/tests/twisted/avahi/tubes/request-muc-tubes.py @@ -10,7 +10,7 @@ from twisted.words.xish import domish from saluttest import exec_test, wait_for_contact_list from servicetest import call_async, EventPattern, wrap_channel, pretty -from constants import * +import constants as cs def test(q, bus, conn): self_name = 'testsuite' + '@' + avahitest.get_host_name() @@ -24,19 +24,19 @@ def test(q, bus, conn): wait_for_contact_list(q, conn) # check if we can request tube channels - properties = conn.Properties.GetAll(CONN_IFACE_REQUESTS) - assert ({CHANNEL_TYPE: CHANNEL_TYPE_STREAM_TUBE, - TARGET_HANDLE_TYPE: HT_ROOM}, - [TARGET_HANDLE, TARGET_ID, STREAM_TUBE_SERVICE], + properties = conn.Properties.GetAll(cs.CONN_IFACE_REQUESTS) + assert ({cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_STREAM_TUBE, + cs.TARGET_HANDLE_TYPE: cs.HT_ROOM}, + [cs.TARGET_HANDLE, cs.TARGET_ID, cs.STREAM_TUBE_SERVICE], ) in properties.get('RequestableChannelClasses'),\ properties['RequestableChannelClasses'] # create muc channel using new API call_async(q, conn.Requests, 'CreateChannel', - { CHANNEL_TYPE: CHANNEL_TYPE_STREAM_TUBE, - TARGET_HANDLE_TYPE: HT_ROOM, - TARGET_ID: 'my-second-room', - STREAM_TUBE_SERVICE: 'loldongs', + { cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_STREAM_TUBE, + cs.TARGET_HANDLE_TYPE: cs.HT_ROOM, + cs.TARGET_ID: 'my-second-room', + cs.STREAM_TUBE_SERVICE: 'loldongs', }) ret, old_sig, new_sig = q.expect_many( @@ -48,40 +48,40 @@ def test(q, bus, conn): chan = wrap_channel(bus.get_object(conn.bus_name, tube_path), 'StreamTube') - handle = conn.RequestHandles(HT_ROOM, ['my-second-room'])[0] + handle = conn.RequestHandles(cs.HT_ROOM, ['my-second-room'])[0] tube_props = ret.value[1] - assert tube_props[CHANNEL_TYPE] == CHANNEL_TYPE_STREAM_TUBE - assert tube_props[TARGET_HANDLE_TYPE] == HT_ROOM - assert tube_props[TARGET_HANDLE] == handle - assert tube_props[TARGET_ID] == 'my-second-room' - assert tube_props[REQUESTED] == True - assert tube_props[INITIATOR_HANDLE] == conn.GetSelfHandle() - assert tube_props[INITIATOR_ID] == self_name + assert tube_props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_STREAM_TUBE + assert tube_props[cs.TARGET_HANDLE_TYPE] == cs.HT_ROOM + assert tube_props[cs.TARGET_HANDLE] == handle + assert tube_props[cs.TARGET_ID] == 'my-second-room' + assert tube_props[cs.REQUESTED] == True + assert tube_props[cs.INITIATOR_HANDLE] == conn.GetSelfHandle() + assert tube_props[cs.INITIATOR_ID] == self_name # text and tube channels are announced channels = new_sig.args[0] assert len(channels) == 1 path, props = channels[0] - assert props[CHANNEL_TYPE] == CHANNEL_TYPE_STREAM_TUBE + assert props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_STREAM_TUBE assert path == tube_path assert props == tube_props - assert props[TARGET_HANDLE_TYPE] == HT_ROOM - assert props[TARGET_HANDLE] == handle - assert props[TARGET_ID] == 'my-second-room' - assert props[INITIATOR_HANDLE] == conn.GetSelfHandle() - assert props[INITIATOR_ID] == self_name + assert props[cs.TARGET_HANDLE_TYPE] == cs.HT_ROOM + assert props[cs.TARGET_HANDLE] == handle + assert props[cs.TARGET_ID] == 'my-second-room' + assert props[cs.INITIATOR_HANDLE] == conn.GetSelfHandle() + assert props[cs.INITIATOR_ID] == self_name # ensure the same channel # TODO: the muc channel doesn't bother to look at existing tubes # before creating a new one. once that's fixed, uncomment this. # yours, ensured_path, _ = conn.Requests.EnsureChannel( -# { CHANNEL_TYPE: CHANNEL_TYPE_STREAM_TUBE, -# TARGET_HANDLE_TYPE: HT_ROOM, -# TARGET_HANDLE: handle, -# STREAM_TUBE_SERVICE: 'loldongs', +# { cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_STREAM_TUBE, +# cs.TARGET_HANDLE_TYPE: cs.HT_ROOM, +# cs.TARGET_HANDLE: handle, +# cs.STREAM_TUBE_SERVICE: 'loldongs', # }) # assert not yours diff --git a/tests/twisted/avahi/tubes/two-muc-stream-tubes.py b/tests/twisted/avahi/tubes/two-muc-stream-tubes.py index 012fc31a..2e3bae53 100644 --- a/tests/twisted/avahi/tubes/two-muc-stream-tubes.py +++ b/tests/twisted/avahi/tubes/two-muc-stream-tubes.py @@ -10,7 +10,7 @@ from servicetest import (wrap_channel, Event, call_async, EventPattern, from twisted.internet.protocol import Factory, Protocol, ClientCreator from twisted.internet import reactor -from constants import * +import constants as cs import tubetestutil as t sample_parameters = dbus.Dictionary({ @@ -80,28 +80,28 @@ def test(q, bus, conn): # request a stream tube channel (new API) conn.Requests.CreateChannel({ - CHANNEL_TYPE: CHANNEL_TYPE_STREAM_TUBE, - TARGET_HANDLE_TYPE: HT_ROOM, - TARGET_ID: muc_name, - STREAM_TUBE_SERVICE: 'test'}) + cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_STREAM_TUBE, + cs.TARGET_HANDLE_TYPE: cs.HT_ROOM, + cs.TARGET_ID: muc_name, + cs.STREAM_TUBE_SERVICE: 'test'}) e = q.expect('dbus-signal', signal='NewChannels') channels = e.args[0] assert len(channels) == 1 # get the list of all channels to check that newly announced ones are in it - all_channels = conn.Properties.Get(CONN_IFACE_REQUESTS, 'Channels', + all_channels = conn.Properties.Get(cs.CONN_IFACE_REQUESTS, 'Channels', byte_arrays=True) path, props = channels[0] - assert props[CHANNEL_TYPE] == CHANNEL_TYPE_STREAM_TUBE - assert props[REQUESTED] == True - assertSameSets([CHANNEL_IFACE_GROUP, CHANNEL_IFACE_TUBE], - props[INTERFACES]) - assert props[STREAM_TUBE_SERVICE] == 'test' - assert props[INITIATOR_HANDLE] == conn1_self_handle - assert props[INITIATOR_ID] == contact1_name - assert props[TARGET_ID] == muc_name + assert props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_STREAM_TUBE + assert props[cs.REQUESTED] == True + assertSameSets([cs.CHANNEL_IFACE_GROUP, cs.CHANNEL_IFACE_TUBE], + props[cs.INTERFACES]) + assert props[cs.STREAM_TUBE_SERVICE] == 'test' + assert props[cs.INITIATOR_HANDLE] == conn1_self_handle + assert props[cs.INITIATOR_ID] == contact1_name + assert props[cs.TARGET_ID] == muc_name assert (path, props) in all_channels, (path, props) @@ -126,9 +126,9 @@ def test(q, bus, conn): # now let's get the text channel so we can invite contact2 using # the utility t.invite_to_muc _, path, _ = conn.Requests.EnsureChannel({ - CHANNEL_TYPE: CHANNEL_TYPE_TEXT, - TARGET_HANDLE_TYPE: HT_ROOM, - TARGET_ID: muc_name}) + cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_TEXT, + cs.TARGET_HANDLE_TYPE: cs.HT_ROOM, + cs.TARGET_ID: muc_name}) text1 = wrap_channel(bus.get_object(conn.bus_name, path), 'Text') t.invite_to_muc(q, text1.Group, conn2, contact2_handle_on_conn1, contact1_handle_on_conn2) @@ -139,15 +139,15 @@ def test(q, bus, conn): assert len(channels) == 1 # get the list of all channels to check that newly announced ones are in it - all_channels = conn2.Properties.Get(CONN_IFACE_REQUESTS, 'Channels', + all_channels = conn2.Properties.Get(cs.CONN_IFACE_REQUESTS, 'Channels', byte_arrays=True) path, props = channels[0] - assert props[REQUESTED] == False - assertSameSets([CHANNEL_IFACE_GROUP, CHANNEL_IFACE_TUBE], - props[INTERFACES]) - assert props[STREAM_TUBE_SERVICE] == 'test' - assert props[TUBE_PARAMETERS] == sample_parameters + assert props[cs.REQUESTED] == False + assertSameSets([cs.CHANNEL_IFACE_GROUP, cs.CHANNEL_IFACE_TUBE], + props[cs.INTERFACES]) + assert props[cs.STREAM_TUBE_SERVICE] == 'test' + assert props[cs.TUBE_PARAMETERS] == sample_parameters assert (path, props) in all_channels, (path, props) |