[telepathy-gabble/telepathy-gabble-0.8] make use of send_disco_reply in tests

Dafydd Harries dafydd.harries at collabora.co.uk
Wed Jan 20 15:33:41 PST 2010


---
 tests/twisted/caps/caps-cache.py               |    5 ++---
 tests/twisted/caps/from-bare-jid.py            |   11 ++++-------
 tests/twisted/caps/hashed-caps.py              |   19 ++++++++-----------
 tests/twisted/caps_helper.py                   |    4 +---
 tests/twisted/jingle/jingletest.py             |    7 ++-----
 tests/twisted/test-fallback-socks5-proxy.py    |   22 ++++++++++++++--------
 tests/twisted/tubes/offer-private-dbus-tube.py |    4 ++--
 7 files changed, 33 insertions(+), 39 deletions(-)

diff --git a/tests/twisted/caps/caps-cache.py b/tests/twisted/caps/caps-cache.py
index e7e37ab..ddbe36c 100644
--- a/tests/twisted/caps/caps-cache.py
+++ b/tests/twisted/caps/caps-cache.py
@@ -11,9 +11,8 @@ from gabbletest import exec_test, make_presence, sync_stream
 import constants as cs
 import ns
 from caps_helper import (
-    compute_caps_hash, make_caps_disco_reply, fake_client_dataforms,
-    presence_and_disco, send_presence, expect_disco, send_disco_reply
-    )
+    compute_caps_hash, fake_client_dataforms, presence_and_disco,
+    send_presence, expect_disco, send_disco_reply)
 
 client = 'http://telepathy.freedesktop.org/fake-client'
 features = [
diff --git a/tests/twisted/caps/from-bare-jid.py b/tests/twisted/caps/from-bare-jid.py
index cdf51fe..22f9c6e 100644
--- a/tests/twisted/caps/from-bare-jid.py
+++ b/tests/twisted/caps/from-bare-jid.py
@@ -8,7 +8,7 @@ from servicetest import (
     assertEquals, assertContains, assertDoesNotContain, EventPattern,
     )
 from gabbletest import make_presence, exec_test
-from caps_helper import compute_caps_hash, make_caps_disco_reply
+from caps_helper import compute_caps_hash, send_disco_reply
 import constants as cs
 import ns
 
@@ -43,8 +43,7 @@ def test(q, bus, conn, stream):
     assertEquals(client + '#' + caps['ver'], query_node.attributes['node'])
 
     # The bare jid replies
-    result = make_caps_disco_reply(stream, event.stanza, features, {})
-    stream.send(result)
+    send_disco_reply(stream, event.stanza, features, {})
 
     # Gabble lets us know their caps have changed. (Gabble used to ignore the
     # reply.)
@@ -96,12 +95,10 @@ def test(q, bus, conn, stream):
     # The bare jid replies! Getting a disco reply from a bare JID when we've
     # got presence from resources used to crash Gabble, but now it just ignores
     # it.
-    result = make_caps_disco_reply(stream, disco2.stanza, features, {})
-    stream.send(result)
+    send_disco_reply(stream, disco2.stanza, features, {})
 
     # Now the resourceful JID replies:
-    result = make_caps_disco_reply(stream, disco3.stanza, features_, {})
-    stream.send(result)
+    send_disco_reply(stream, disco3.stanza, features_, {})
 
     # Gabble should announce that the contact has acquired some caps.
     e = q.expect('dbus-signal', signal='CapabilitiesChanged')
diff --git a/tests/twisted/caps/hashed-caps.py b/tests/twisted/caps/hashed-caps.py
index 375f92e..c50e052 100644
--- a/tests/twisted/caps/hashed-caps.py
+++ b/tests/twisted/caps/hashed-caps.py
@@ -29,8 +29,8 @@ from servicetest import sync_dbus, EventPattern
 import constants as cs
 import ns
 from caps_helper import (
-    compute_caps_hash, make_caps_disco_reply, fake_client_dataforms,
-    )
+    compute_caps_hash, make_caps_disco_reply, send_disco_reply,
+    fake_client_dataforms)
 
 caps_changed_flag = False
 
@@ -80,8 +80,7 @@ def test_hash(q, bus, conn, stream, contact, contact_handle, client):
         client + '#' + '0.1'
 
     # send good reply
-    stream.send(make_caps_disco_reply(stream, event.stanza,
-        jingle_av_features))
+    send_disco_reply(stream, event.stanza, jingle_av_features)
 
     # we can now do audio calls
     event = q.expect('dbus-signal', signal='CapabilitiesChanged')
@@ -104,8 +103,8 @@ def test_hash(q, bus, conn, stream, contact, contact_handle, client):
         client + '#' + caps['ver']
 
     # send bogus reply
-    stream.send(make_caps_disco_reply(stream, event.stanza,
-        ['http://jabber.org/protocol/bogus-feature']))
+    send_disco_reply(stream, event.stanza,
+        ['http://jabber.org/protocol/bogus-feature'])
 
     # don't receive any D-Bus signal
     sync_dbus(bus, q, conn)
@@ -164,9 +163,8 @@ def test_hash(q, bus, conn, stream, contact, contact_handle, client):
     assert caps_changed_flag == False
 
     # send good reply
-    result = make_caps_disco_reply(stream, event.stanza, jingle_av_features,
-        fake_client_dataforms)
-    stream.send(result)
+    send_disco_reply(
+        stream, event.stanza, jingle_av_features, fake_client_dataforms)
 
     # we can now do audio calls
     event = q.expect('dbus-signal', signal='CapabilitiesChanged',
@@ -252,8 +250,7 @@ def test_two_clients(q, bus, conn, stream, contact1, contact2,
         assert caps_changed_flag == False
 
         # send good reply
-        result = make_caps_disco_reply(stream, event.stanza, jingle_av_features)
-        stream.send(result)
+        send_disco_reply(stream, event.stanza, jingle_av_features)
 
     # we can now do audio calls with both contacts
     event = q.expect('dbus-signal', signal='CapabilitiesChanged',
diff --git a/tests/twisted/caps_helper.py b/tests/twisted/caps_helper.py
index 82d2d1b..2c5b40a 100644
--- a/tests/twisted/caps_helper.py
+++ b/tests/twisted/caps_helper.py
@@ -293,9 +293,7 @@ def expect_disco(q, contact, client, caps):
     return event.stanza
 
 def send_disco_reply(stream, stanza, features, dataforms={}):
-    # send good reply
-    result = make_caps_disco_reply(stream, stanza, features, dataforms)
-    stream.send(result)
+    stream.send(make_caps_disco_reply(stream, stanza, features, dataforms))
 
 if __name__ == '__main__':
     # example from XEP-0115
diff --git a/tests/twisted/jingle/jingletest.py b/tests/twisted/jingle/jingletest.py
index ca84deb..2a9e713 100644
--- a/tests/twisted/jingle/jingletest.py
+++ b/tests/twisted/jingle/jingletest.py
@@ -7,7 +7,7 @@ from gabbletest import make_presence
 from twisted.words.xish import domish
 from twisted.words.protocols.jabber.client import IQ
 import dbus
-from caps_helper import make_caps_disco_reply
+from caps_helper import send_disco_reply
 
 class JingleTest:
 
@@ -109,10 +109,7 @@ class JingleTest:
 
 
     def send_remote_disco_reply(self, stanza):
-        reply = make_caps_disco_reply(self.stream, stanza,
-            self.remote_feats)
-        self.stream.send(reply.toXml())
-
+        send_disco_reply(self.stream, stanza, self.remote_feats)
 
     def incoming_call(self, codec_parameters=None):
         self.direction = 'incoming'
diff --git a/tests/twisted/test-fallback-socks5-proxy.py b/tests/twisted/test-fallback-socks5-proxy.py
index d9f93d8..a7ed358 100644
--- a/tests/twisted/test-fallback-socks5-proxy.py
+++ b/tests/twisted/test-fallback-socks5-proxy.py
@@ -1,15 +1,21 @@
-import dbus
+
 import socket
-from gabbletest import exec_test, elem, elem_iq, sync_stream, make_presence, send_error_reply,\
-    make_result_iq, sync_stream
-from servicetest import EventPattern, call_async, assertEquals, assertLength, assertDoesNotContain
-from caps_helper import make_caps_disco_reply
 
-from twisted.words.xish import xpath
+from gabbletest import (
+    exec_test, elem, elem_iq, sync_stream, make_presence, send_error_reply,
+    make_result_iq, sync_stream)
+from servicetest import (
+    EventPattern, call_async, assertEquals, assertLength,
+    assertDoesNotContain)
+from caps_helper import send_disco_reply
+from bytestream import create_from_si_offer, BytestreamS5B
 
 import ns
 import constants as cs
-from bytestream import create_from_si_offer, BytestreamS5B
+
+from twisted.words.xish import xpath
+
+import dbus
 
 proxy_query_events = [
     EventPattern('stream-iq', to='fallback1-proxy.localhost', iq_type='get', query_ns=ns.BYTESTREAMS),
@@ -36,7 +42,7 @@ def connect_and_announce_alice(q, bus, conn, stream):
     disco_event = q.expect('stream-iq', to='alice at localhost/Test',
         query_ns=ns.DISCO_INFO)
 
-    stream.send(make_caps_disco_reply(stream, disco_event.stanza, [ns.TUBES, ns.FILE_TRANSFER]))
+    send_disco_reply(stream, disco_event.stanza, [ns.TUBES, ns.FILE_TRANSFER])
     sync_stream(q, stream)
 
     q.unforbid_events(proxy_query_events)
diff --git a/tests/twisted/tubes/offer-private-dbus-tube.py b/tests/twisted/tubes/offer-private-dbus-tube.py
index 9062fe4..5fd3b7b 100644
--- a/tests/twisted/tubes/offer-private-dbus-tube.py
+++ b/tests/twisted/tubes/offer-private-dbus-tube.py
@@ -13,7 +13,7 @@ import tubetestutil as t
 from twisted.words.xish import xpath
 import ns
 from bytestream import create_from_si_offer, announce_socks5_proxy
-from caps_helper import make_caps_disco_reply
+from caps_helper import send_disco_reply
 
 sample_parameters = dbus.Dictionary({
     's': 'hello',
@@ -305,7 +305,7 @@ def test(q, bus, conn, stream, bytestream_cls, access_control):
         )
 
     # reply to disco query
-    stream.send(make_caps_disco_reply(stream, disco_event.stanza, [ns.TUBES]))
+    send_disco_reply(stream, disco_event.stanza, [ns.TUBES])
 
     sync_stream(q, stream)
 
-- 
1.5.6.5




More information about the telepathy-commits mailing list