[telepathy-gabble/telepathy-gabble-0.8] Break up caps-cache.py

Will Thompson will.thompson at collabora.co.uk
Thu Sep 10 07:33:51 PDT 2009


I'll re-use some of the parts to make the test slightly more interesting
shortly.
---
 tests/twisted/caps/caps-cache.py |   30 ++++++++++++++++++++++--------
 1 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/tests/twisted/caps/caps-cache.py b/tests/twisted/caps/caps-cache.py
index edbb4de..c21f79b 100644
--- a/tests/twisted/caps/caps-cache.py
+++ b/tests/twisted/caps/caps-cache.py
@@ -23,6 +23,15 @@ features = [
 
 def presence_and_disco(q, conn, stream, contact, disco,
                        caps, dataforms={}):
+    h = send_presence(q, conn, stream, contact, caps)
+
+    if disco:
+        stanza = expect_disco(q, contact, caps)
+        send_disco_reply(stream, stanza, dataforms)
+
+    expect_caps(q, conn, h)
+
+def send_presence(q, conn, stream, contact, caps):
     h = conn.RequestHandles(cs.HT_CONTACT, [contact])[0]
 
     stream.send(make_presence(contact, status='hello'))
@@ -42,16 +51,21 @@ def presence_and_disco(q, conn, stream, contact, disco,
     # send updated presence with Jingle caps info
     stream.send(make_presence(contact, status='hello', caps=caps))
 
-    if disco:
-        # Gabble looks up our capabilities
-        event = q.expect('stream-iq', to=contact, query_ns=ns.DISCO_INFO)
-        assertEquals(client + '#' + caps['ver'], event.query['node'])
+    return h
+
+def expect_disco(q, contact, caps):
+    # Gabble looks up our capabilities
+    event = q.expect('stream-iq', to=contact, query_ns=ns.DISCO_INFO)
+    assertEquals(client + '#' + caps['ver'], event.query['node'])
+
+    return event.stanza
 
-        # send good reply
-        result = make_caps_disco_reply(stream, event.stanza, features,
-            dataforms)
-        stream.send(result)
+def send_disco_reply(stream, stanza, dataforms):
+    # send good reply
+    result = make_caps_disco_reply(stream, stanza, features, dataforms)
+    stream.send(result)
 
+def expect_caps(q, conn, h):
     # we can now do audio calls
     event = q.expect('dbus-signal', signal='CapabilitiesChanged')
     assertContains((h, cs.CHANNEL_TYPE_STREAMED_MEDIA, 3, cs.MEDIA_CAP_AUDIO),
-- 
1.5.6.5




More information about the telepathy-commits mailing list