telepathy-gabble: tube tests: make sure to catch the right MUC presence stanza
Guillaume Desmottes
gdesmott at kemper.freedesktop.org
Fri Oct 4 03:59:17 PDT 2013
Module: telepathy-gabble
Branch: master
Commit: c4c284b0d15a070f4b760b724bef1525ea6a410d
URL: http://cgit.freedesktop.org/telepathy/telepathy-gabble/commit/?id=c4c284b0d15a070f4b760b724bef1525ea6a410d
Author: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
Date: Thu Oct 3 16:00:01 2013 +0200
tube tests: make sure to catch the right MUC presence stanza
Not requesting the room handle any more will have a side effect to catch
another presence stanza. Make sure to wait for the one containing the tube.
---
tests/twisted/tubes/accept-muc-dbus-tube.py | 3 ++-
tests/twisted/tubes/offer-muc-dbus-tube.py | 2 +-
tests/twisted/tubes/offer-muc-stream-tube.py | 4 ++--
tests/twisted/tubes/tubetestutil.py | 5 +++++
4 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/tests/twisted/tubes/accept-muc-dbus-tube.py b/tests/twisted/tubes/accept-muc-dbus-tube.py
index d0dadac..2606fa2 100644
--- a/tests/twisted/tubes/accept-muc-dbus-tube.py
+++ b/tests/twisted/tubes/accept-muc-dbus-tube.py
@@ -11,6 +11,7 @@ from twisted.words.xish import xpath
import ns
from mucutil import join_muc_and_check
+import tubetestutil as t
def test(q, bus, conn, stream, access_control):
iq_event = q.expect('stream-iq', to=None, query_ns='vcard-temp',
@@ -75,7 +76,7 @@ def test(q, bus, conn, stream, access_control):
EventPattern('dbus-return', method='Accept'),
EventPattern('dbus-signal', signal='DBusNamesChanged', interface=cs.CHANNEL_TYPE_DBUS_TUBE),
EventPattern('dbus-signal', signal='DBusNamesChanged', interface=cs.CHANNEL_TYPE_DBUS_TUBE),
- EventPattern('stream-presence', to='chat at conf.localhost/test'))
+ EventPattern('stream-presence', to='chat at conf.localhost/test', predicate=lambda e: t.presence_contains_tube(e)))
tube_addr = return_event.value[0]
assert len(tube_addr) > 0
diff --git a/tests/twisted/tubes/offer-muc-dbus-tube.py b/tests/twisted/tubes/offer-muc-dbus-tube.py
index 563e001..ff10045 100644
--- a/tests/twisted/tubes/offer-muc-dbus-tube.py
+++ b/tests/twisted/tubes/offer-muc-dbus-tube.py
@@ -163,7 +163,7 @@ def test(q, bus, conn, stream, access_control):
call_async(q, tube_chan.DBusTube, 'Offer', sample_parameters, access_control)
presence_event, return_event, status_event, dbus_changed_event = q.expect_many(
- EventPattern('stream-presence', to='chat2 at conf.localhost/test'),
+ EventPattern('stream-presence', to='chat2 at conf.localhost/test', predicate=lambda e: t.presence_contains_tube(e)),
EventPattern('dbus-return', method='Offer'),
EventPattern('dbus-signal', signal='TubeChannelStateChanged', args=[cs.TUBE_CHANNEL_STATE_OPEN]),
EventPattern('dbus-signal', signal='DBusNamesChanged', interface=cs.CHANNEL_TYPE_DBUS_TUBE))
diff --git a/tests/twisted/tubes/offer-muc-stream-tube.py b/tests/twisted/tubes/offer-muc-stream-tube.py
index ce7f338..1a36045 100644
--- a/tests/twisted/tubes/offer-muc-stream-tube.py
+++ b/tests/twisted/tubes/offer-muc-stream-tube.py
@@ -101,7 +101,7 @@ def test(q, bus, conn, stream, bytestream_cls,
cs.TARGET_ID: 'chat at conf.localhost',
cs.STREAM_TUBE_SERVICE: 'newecho',
}
- _, _, new_tube_path, new_tube_props = \
+ _, new_tube_path, new_tube_props = \
join_muc(q, bus, conn, stream, 'chat at conf.localhost', request)
e = q.expect('dbus-signal', signal='NewChannels',
@@ -129,7 +129,7 @@ def test(q, bus, conn, stream, bytestream_cls,
call_async(q, tube_chan.StreamTube, 'Offer', address_type, address, access_control, {'foo': 'bar'})
stream_event, _, status_event = q.expect_many(
- EventPattern('stream-presence', to='chat at conf.localhost/test'),
+ EventPattern('stream-presence', to='chat at conf.localhost/test', predicate=lambda e: t.presence_contains_tube(e)),
EventPattern('dbus-return', method='Offer'),
EventPattern('dbus-signal', signal='TubeChannelStateChanged', args=[cs.TUBE_CHANNEL_STATE_OPEN]))
diff --git a/tests/twisted/tubes/tubetestutil.py b/tests/twisted/tubes/tubetestutil.py
index 9edf27b..3c53d15 100644
--- a/tests/twisted/tubes/tubetestutil.py
+++ b/tests/twisted/tubes/tubetestutil.py
@@ -21,6 +21,7 @@ from twisted.internet import reactor
from twisted.internet.protocol import Factory, Protocol
from twisted.internet.error import CannotListenError
from twisted.internet import tcp
+from twisted.words.xish import xpath
_to_cleanup = []
@@ -373,3 +374,7 @@ def exec_stream_tube_test(test):
def exec_dbus_tube_test(test):
exec_tube_test(test, cs.SOCKET_ACCESS_CONTROL_CREDENTIALS)
exec_tube_test(test, cs.SOCKET_ACCESS_CONTROL_LOCALHOST)
+
+def presence_contains_tube(e):
+ return xpath.queryForNodes('/presence/tubes[@xmlns="%s"]/tube'
+ % ns.TUBES, e.stanza) is not None
More information about the telepathy-commits
mailing list