[Telepathy-commits] [telepathy-salut/master] Test requesting tubes to nonexistant jids

Will Thompson will.thompson at collabora.co.uk
Fri Feb 6 03:15:01 PST 2009


---
 tests/twisted/Makefile.am                        |    3 +-
 tests/twisted/avahi/tubes-to-nonexistant-jids.py |   51 ++++++++++++++++++++++
 2 files changed, 53 insertions(+), 1 deletions(-)
 create mode 100644 tests/twisted/avahi/tubes-to-nonexistant-jids.py

diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index ed186de..b8b3ca6 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -39,7 +39,8 @@ TWISTED_AVAHI_TESTS = \
 	avahi/test-tube.py \
 	avahi/test-two-muc-stream-tubes.py \
 	avahi/test-two-tubes.py \
-	avahi/test-tube-close.py
+	avahi/test-tube-close.py \
+	avahi/tubes-to-nonexistant-jids.py
 
 TWISTED_AVAHI_OLPC_TESTS = \
 	avahi/test-olpc-activity-announcements.py
diff --git a/tests/twisted/avahi/tubes-to-nonexistant-jids.py b/tests/twisted/avahi/tubes-to-nonexistant-jids.py
new file mode 100644
index 0000000..60c7ee4
--- /dev/null
+++ b/tests/twisted/avahi/tubes-to-nonexistant-jids.py
@@ -0,0 +1,51 @@
+"""
+Test that requests for Tubes and StreamTube channels to jids which aren't
+actually on the network fail gracefully with NotAvailable
+"""
+
+from saluttest import exec_test
+
+from constants import (
+    HT_CONTACT, CONN_IFACE_REQUESTS,
+    CHANNEL_TYPE, TARGET_HANDLE_TYPE, TARGET_HANDLE,
+    CHANNEL_TYPE_TUBES, CHANNEL_TYPE_STREAM_TUBE,
+    NOT_AVAILABLE
+    )
+
+import dbus
+
+arbitrary_jids = [ "DooN4Bei at TheeK6bo-Tegh4aci", "ahrui1iM at Dai6igho-ADetaes3" ]
+
+def test(q, bus, conn):
+    conn.Connect()
+    q.expect('dbus-signal', signal='StatusChanged', args=[0L, 0L])
+
+    h1, h2 = conn.RequestHandles(HT_CONTACT, arbitrary_jids)
+
+    try:
+        conn.RequestChannel(CHANNEL_TYPE_TUBES, HT_CONTACT, h1, True)
+    except dbus.DBusException, e:
+        assert e.get_dbus_name() == NOT_AVAILABLE, e.get_dbus_name()
+    else:
+        assert False
+
+    requestotron = dbus.Interface(conn, CONN_IFACE_REQUESTS)
+
+    try:
+        requestotron.CreateChannel({
+            CHANNEL_TYPE: CHANNEL_TYPE_STREAM_TUBE,
+            TARGET_HANDLE_TYPE: HT_CONTACT,
+            TARGET_HANDLE: h2,
+            CHANNEL_TYPE_STREAM_TUBE + ".Service": "com.example",
+        })
+    except dbus.DBusException, e:
+        print e
+        assert e.get_dbus_name() == NOT_AVAILABLE, e.get_dbus_name()
+    else:
+        assert False
+
+    conn.Disconnect()
+    q.expect('dbus-signal', signal='StatusChanged', args=[2, 1])
+
+if __name__ == '__main__':
+    exec_test(test)
-- 
1.5.6.5




More information about the telepathy-commits mailing list