summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2012-05-29 10:52:37 +0100
committerJonny Lamb <jonny.lamb@collabora.co.uk>2012-05-31 13:52:39 +0100
commitdcd1a084679d113b3b9b63bcb7df526f1b86cc1b (patch)
tree8084241ddc78d85fd116e4fe266475b3aa259d59 /tests
parentb5ee1159b0a10ba187bb1ddb604febe6ebdf0e7e (diff)
downloadtelepathy-salut-dcd1a084679d113b3b9b63bcb7df526f1b86cc1b.tar.gz
tube tests: stop testing requesting MUC Tubes channels
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
Diffstat (limited to 'tests')
-rw-r--r--tests/twisted/avahi/tubes/request-muc-tubes.py101
-rw-r--r--tests/twisted/avahi/tubes/two-muc-stream-tubes.py113
2 files changed, 29 insertions, 185 deletions
diff --git a/tests/twisted/avahi/tubes/request-muc-tubes.py b/tests/twisted/avahi/tubes/request-muc-tubes.py
index 999e85bb..6ac74bd6 100644
--- a/tests/twisted/avahi/tubes/request-muc-tubes.py
+++ b/tests/twisted/avahi/tubes/request-muc-tubes.py
@@ -9,7 +9,7 @@ import avahitest
from twisted.words.xish import domish
from saluttest import exec_test, wait_for_contact_list
-from servicetest import call_async, EventPattern, make_channel_proxy
+from servicetest import call_async, EventPattern, wrap_channel
from constants import *
def test(q, bus, conn):
@@ -24,67 +24,19 @@ def test(q, bus, conn):
wait_for_contact_list(q, conn)
# check if we can request roomlist channels
- properties = conn.GetAll(CONN_IFACE_REQUESTS, dbus_interface=PROPERTIES_IFACE)
+ properties = conn.Properties.GetAll(CONN_IFACE_REQUESTS)
assert ({CHANNEL_TYPE: CHANNEL_TYPE_TUBES,
TARGET_HANDLE_TYPE: HT_ROOM},
[TARGET_HANDLE, TARGET_ID],
) in properties.get('RequestableChannelClasses'),\
properties['RequestableChannelClasses']
- # request a muc tubes channel using the old API
- handle = conn.RequestHandles(HT_ROOM, ['my-first-room'])[0]
- call_async(q, conn, 'RequestChannel', CHANNEL_TYPE_TUBES, HT_ROOM, handle, True)
-
- ret, old_sig, new_sig = q.expect_many(
- EventPattern('dbus-return', method='RequestChannel'),
- EventPattern('dbus-signal', signal='NewChannel'),
- EventPattern('dbus-signal', signal='NewChannels'),
- )
-
- path1 = ret.value[0]
- chan = make_channel_proxy(conn, path1, "Channel")
-
- # text and tubes channels are announced
- channels = new_sig.args[0]
- assert len(channels) == 2
- got_text, got_tubes = False, False
-
- for path, props in channels:
- if props[CHANNEL_TYPE] == CHANNEL_TYPE_TEXT:
- got_text = True
- assert props[REQUESTED] == False
- elif props[CHANNEL_TYPE] == CHANNEL_TYPE_TUBES:
- got_tubes = True
- assert props[REQUESTED] == True
- else:
- assert False
-
- assert props[TARGET_HANDLE_TYPE] == HT_ROOM
- assert props[TARGET_HANDLE] == handle
- assert props[TARGET_ID] == 'my-first-room'
- assert props[INITIATOR_HANDLE] == conn.GetSelfHandle()
- assert props[INITIATOR_ID] == self_name
-
- # Exercise basic Channel Properties from spec 0.17.7
- channel_props = chan.GetAll(CHANNEL, dbus_interface=PROPERTIES_IFACE)
- 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,\
- channel_props.get('TargetHandleType')
- assert channel_props.get('ChannelType') == \
- CHANNEL_TYPE_TUBES, channel_props.get('ChannelType')
- assert channel_props['Requested'] == True
- assert channel_props['InitiatorID'] == self_name
- assert channel_props['InitiatorHandle'] == conn.GetSelfHandle()
-
- requestotron = dbus.Interface(conn, CONN_IFACE_REQUESTS)
-
# create muc channel using new API
- call_async(q, requestotron, 'CreateChannel',
- { CHANNEL_TYPE: CHANNEL_TYPE_TUBES,
+ 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',
})
ret, old_sig, new_sig = q.expect_many(
@@ -93,23 +45,24 @@ def test(q, bus, conn):
EventPattern('dbus-signal', signal='NewChannels'),
)
path2 = ret.value[0]
- chan = make_channel_proxy(conn, path2, "Channel")
+ chan = wrap_channel(bus.get_object(conn.bus_name, path2),
+ 'StreamTube')
handle = conn.RequestHandles(HT_ROOM, ['my-second-room'])[0]
- tubes_props = ret.value[1]
- assert tubes_props[CHANNEL_TYPE] == CHANNEL_TYPE_TUBES
- assert tubes_props[TARGET_HANDLE_TYPE] == HT_ROOM
- assert tubes_props[TARGET_HANDLE] == handle
- assert tubes_props[TARGET_ID] == 'my-second-room'
- assert tubes_props[REQUESTED] == True
- assert tubes_props[INITIATOR_HANDLE] == conn.GetSelfHandle()
- assert tubes_props[INITIATOR_ID] == self_name
+ 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
- # text and tubes channels are announced
+ # text and tube channels are announced
channels = new_sig.args[0]
- assert len(channels) == 2
- got_text, got_tubes = False, False
+ assert len(channels) == 3
+ got_text, got_tubes, got_tube = False, False, False
for path, props in channels:
if props[CHANNEL_TYPE] == CHANNEL_TYPE_TEXT:
@@ -117,8 +70,11 @@ def test(q, bus, conn):
assert props[REQUESTED] == False
elif props[CHANNEL_TYPE] == CHANNEL_TYPE_TUBES:
got_tubes = True
- assert props == tubes_props
+ assert props[REQUESTED] == False
+ elif props[CHANNEL_TYPE] == CHANNEL_TYPE_STREAM_TUBE:
+ got_tube = True
assert path == path2
+ assert props == tube_props
else:
assert False
@@ -128,13 +84,17 @@ def test(q, bus, conn):
assert props[INITIATOR_HANDLE] == conn.GetSelfHandle()
assert props[INITIATOR_ID] == self_name
- # ensure roomlist channel
- yours, ensured_path, ensured_props = requestotron.EnsureChannel(
- { CHANNEL_TYPE: CHANNEL_TYPE_TUBES,
+ # ensure the same channel
+ yours, ensured_path, ensured_props = conn.Requests.EnsureChannel(
+ { CHANNEL_TYPE: CHANNEL_TYPE_STREAM_TUBE,
TARGET_HANDLE_TYPE: HT_ROOM,
TARGET_HANDLE: handle,
+ STREAM_TUBE_SERVICE: 'loldongs',
})
+ # TODO: get rid of Tubes and this'll start making more sense
+ return
+
assert not yours
assert ensured_path == path2, (ensured_path, path2)
@@ -142,10 +102,7 @@ def test(q, bus, conn):
q.expect_many(
EventPattern('dbus-signal', signal='Closed',
- path=path1),
- EventPattern('dbus-signal', signal='Closed',
path=path2),
- EventPattern('dbus-signal', signal='ChannelClosed', args=[path1]),
EventPattern('dbus-signal', signal='ChannelClosed', args=[path2]),
EventPattern('dbus-signal', signal='StatusChanged', args=[2, 1]),
)
diff --git a/tests/twisted/avahi/tubes/two-muc-stream-tubes.py b/tests/twisted/avahi/tubes/two-muc-stream-tubes.py
index 2c2b4b83..50913668 100644
--- a/tests/twisted/avahi/tubes/two-muc-stream-tubes.py
+++ b/tests/twisted/avahi/tubes/two-muc-stream-tubes.py
@@ -74,119 +74,6 @@ def test(q, bus, conn):
conn1_self_handle = conn.GetSelfHandle()
- # first connection: join muc
- muc_handle1, group1 = t.join_muc(q, conn, muc_name)
-
- t.invite_to_muc(q, group1, conn2, contact2_handle_on_conn1, contact1_handle_on_conn2)
-
- # first connection: offer a muc stream tube (old API)
- tubes1_path = conn.RequestChannel(CHANNEL_TYPE_TUBES, HT_ROOM, muc_handle1,
- True)
- contact1_tubes = wrap_channel(
- bus.get_object(conn.bus_name, tubes1_path),
- 'Tubes')
-
- q.expect('dbus-signal', signal='NewChannel',
- args=[tubes1_path, CHANNEL_TYPE_TUBES, HT_ROOM, muc_handle1, True])
-
- conn1_tube_id = contact1_tubes.Tubes.OfferStreamTube("http",
- sample_parameters, SOCKET_ADDRESS_TYPE_UNIX,
- dbus.ByteArray(server_socket_address),
- SOCKET_ACCESS_CONTROL_LOCALHOST, "")
-
- e = q.expect('dbus-signal', signal='NewTube', path=tubes1_path)
- tube = e.args
- assert tube[1] == conn1_self_handle # initiator
- assert tube[2] == 1 # type = stream tube
- assert tube[3] == 'http' # service
- assert tube[4] == sample_parameters # paramaters
- assert tube[5] == TUBE_CHANNEL_STATE_OPEN
-
- contact2_channeltype = None
- while contact2_channeltype == None:
- e = q.expect('dbus-signal', signal='NewChannel')
- if (e.args[1] == CHANNEL_TYPE_TUBES) and \
- (e.path.endswith("testsuite2") == True):
- tubes2_path = e.args[0]
- contact2_channeltype = e.args[1]
-
- contact2_tubes = wrap_channel(
- bus.get_object(conn2.bus_name, tubes2_path),
- 'Tubes')
-
- contact2_tubes_list = contact2_tubes.Tubes.ListTubes()
- assert len(contact2_tubes_list) == 1
- contact2_tube = contact2_tubes_list[0]
- assert contact2_tube[0] is not None # tube id
- conn2_tube_id = contact2_tube[0]
- assert contact2_tube[1] is not None # initiator
- assert contact2_tube[2] == 1 # type = stream tube
- assert contact2_tube[3] == 'http' # service = http
- assert contact2_tube[4] is not None # parameters
- assert contact2_tube[5] == 0, contact2_tube[5] # status = local pending
-
- # second connection: accept the tube (old API)
- unix_socket_adr = contact2_tubes.Tubes.AcceptStreamTube(
- contact2_tube[0], 0, 0, '', byte_arrays=True)
-
- e = q.expect('dbus-signal', signal='TubeStateChanged', path=tubes2_path)
- id, state = e.args
- assert id == conn2_tube_id
- assert state == TUBE_CHANNEL_STATE_OPEN
-
- client = ClientCreator(reactor, ClientGreeter)
- client.connectUNIX(unix_socket_adr).addCallback(client_connected_cb)
-
- # server got the connection
- _, e = q.expect_many(
- EventPattern('server-connected'),
- EventPattern('client-connected'))
-
- client_transport = e.transport
-
- sig, e = q.expect_many(
- EventPattern('dbus-signal', signal='StreamTubeNewConnection',
- path=tubes1_path),
- EventPattern('client-data-received'))
-
- id, handle = sig.args
- assert id == conn1_tube_id
- assert handle == contact2_handle_on_conn1
-
- # client receives server's welcome message
- assert e.data == SERVER_WELCOME_MSG
-
- client_transport.write(test_string)
-
- server_received, client_received = q.expect_many(
- EventPattern('server-data-received'),
- EventPattern('client-data-received'))
-
- assert server_received.data == test_string
- assert client_received.data == string.swapcase(test_string)
-
- # contact1 closes the tube
- contact1_tubes.Close(conn1_tube_id)
- q.expect('dbus-signal', signal='TubeClosed', args=[conn1_tube_id])
-
- # contact2 closes the tube
- contact2_tubes.Tubes.CloseTube(conn2_tube_id)
- q.expect('dbus-signal', signal='TubeClosed', args=[conn2_tube_id])
-
- # Now contact1 will create a new muc stream tube to another room using the
- # new API
-
- server_socket_address = listen_for_connections()
-
- # Can we request muc stream tubes?
- 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]
- ) in properties.get('RequestableChannelClasses'),\
- properties['RequestableChannelClasses']
-
# request a stream tube channel (new API)
conn.Requests.CreateChannel({
CHANNEL_TYPE: CHANNEL_TYPE_STREAM_TUBE,