telepathy-gabble: jingle/test-wait-for-caps: use jingletest2
Will Thompson
wjt at kemper.freedesktop.org
Thu Dec 6 04:46:05 PST 2012
Module: telepathy-gabble
Branch: master
Commit: d4ffb25c14d5686c9419ece0826fe2e0de9491fe
URL: http://cgit.freedesktop.org/telepathy/telepathy-gabble/commit/?id=d4ffb25c14d5686c9419ece0826fe2e0de9491fe
Author: Will Thompson <will.thompson at collabora.co.uk>
Date: Mon Nov 26 09:20:46 2012 +0000
jingle/test-wait-for-caps: use jingletest2
---
tests/twisted/jingle/jingletest2.py | 12 ++++++++----
tests/twisted/jingle/test-wait-for-caps.py | 22 ++++++++++------------
2 files changed, 18 insertions(+), 16 deletions(-)
diff --git a/tests/twisted/jingle/jingletest2.py b/tests/twisted/jingle/jingletest2.py
index 74133c4..688d9ec 100644
--- a/tests/twisted/jingle/jingletest2.py
+++ b/tests/twisted/jingle/jingletest2.py
@@ -621,19 +621,23 @@ class JingleTest2(object):
if send_presence:
self.send_presence_and_caps()
- def send_presence_and_caps(self):
+ def send_presence(self):
# We need remote end's presence for capabilities
self.stream.send(self.jp.xml(
self.jp.Presence(self.peer, self.jid, self.remote_caps)))
# Gabble doesn't trust it, so makes a disco
- event = self.q.expect('stream-iq', query_ns=ns.DISCO_INFO, to=self.peer)
+ return self.q.expect('stream-iq', query_ns=ns.DISCO_INFO, to=self.peer)
- # jt.send_remote_disco_reply(event.stanza)
- self.stream.send(self.jp.xml(self.jp.ResultIq(self.jid, event.stanza,
+ def send_remote_disco_reply(self, query_stanza):
+ self.stream.send(self.jp.xml(self.jp.ResultIq(self.jid, query_stanza,
[ self.jp.Query(None, ns.DISCO_INFO,
[ self.jp.Feature(x) for x in self.jp.features ]) ]) ))
+ def send_presence_and_caps(self):
+ event = self.send_presence()
+ self.send_remote_disco_reply(event.stanza)
+
# Force Gabble to process the caps before doing any more Jingling
sync_stream(self.q, self.stream)
diff --git a/tests/twisted/jingle/test-wait-for-caps.py b/tests/twisted/jingle/test-wait-for-caps.py
index 47afe7d..98221ef 100644
--- a/tests/twisted/jingle/test-wait-for-caps.py
+++ b/tests/twisted/jingle/test-wait-for-caps.py
@@ -7,12 +7,11 @@ call until caps have arrived.
from functools import partial
from gabbletest import exec_test
from servicetest import make_channel_proxy, call_async, sync_dbus
-import jingletest
+import jingletest2
import dbus
import constants as cs
-import ns
from config import VOIP_ENABLED
@@ -21,8 +20,11 @@ if not VOIP_ENABLED:
raise SystemExit(77)
def test(q, bus, conn, stream, channel_type):
- jt = jingletest.JingleTest(stream, 'test at localhost', 'foo at bar.com/Foo')
- jt2 = jingletest.JingleTest(stream, 'test at localhost', 'foo2 at bar.com/Foo')
+ jp = jingletest2.JingleProtocol031()
+ jt = jingletest2.JingleTest2(jp, conn, q, stream, 'test at localhost',
+ 'foo at bar.com/Foo')
+ jt2 = jingletest2.JingleTest2(jp, conn, q, stream, 'test at localhost',
+ 'foo2 at bar.com/Foo')
# Make gabble think this is a different client
jt2.remote_caps['node'] = 'http://example.com/fake-client1'
@@ -31,7 +33,7 @@ def test(q, bus, conn, stream, channel_type):
def run_test(q, bus, conn, stream, jt, request_before_presence, channel_type):
"""
- Requests streams on a media channel to jt.remote_jid, either before their
+ Requests streams on a media channel to jt.peer, either before their
presence is received (if request_before_presence is True) or after their
presence is received but before we've got a disco response for their
capabilities (otherwise).
@@ -42,7 +44,7 @@ def run_test(q, bus, conn, stream, jt, request_before_presence, channel_type):
# will tentatively allow channel creation and contact handle addition
request = dbus.Dictionary({ cs.CHANNEL_TYPE: channel_type,
cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT,
- cs.TARGET_ID: jt.remote_jid
+ cs.TARGET_ID: jt.peer,
}, signature='sv')
if channel_type == cs.CHANNEL_TYPE_CALL:
@@ -65,10 +67,6 @@ def run_test(q, bus, conn, stream, jt, request_before_presence, channel_type):
else:
call_async(q, conn.Requests, 'CreateChannel', request)
- def send_presence():
- jt.send_remote_presence()
- return q.expect('stream-iq', query_ns=ns.DISCO_INFO, to=jt.remote_jid)
-
if request_before_presence:
# Request streams before either <presence> or caps have arrived. Gabble
# should wait for both to arrive before returning from RequestStreams.
@@ -78,9 +76,9 @@ def run_test(q, bus, conn, stream, jt, request_before_presence, channel_type):
sync_dbus(bus, q, conn)
# Now send the presence.
- info_event = send_presence()
+ info_event = jt.send_presence()
else:
- info_event = send_presence()
+ info_event = jt.send_presence()
# Now call RequestStreams; it should wait for the disco reply.
call_request_streams()
More information about the telepathy-commits
mailing list