[telepathy-gabble/master] Test disconnecting on <conflict/>

Will Thompson will.thompson at collabora.co.uk
Thu Apr 16 05:42:56 PDT 2009


---
 tests/twisted/connect/test-fail.py |   33 ++++++++++++++++++++++++++-------
 tests/twisted/ns.py                |    1 +
 2 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/tests/twisted/connect/test-fail.py b/tests/twisted/connect/test-fail.py
index a7c5e3e..c27b3fa 100644
--- a/tests/twisted/connect/test-fail.py
+++ b/tests/twisted/connect/test-fail.py
@@ -1,17 +1,36 @@
-
 """
-Test network error handling.
+Test various ways in which connections can fail.
 """
 
+from twisted.words.xish import domish
+from twisted.words.protocols.jabber import xmlstream
+
 import dbus
 
 from gabbletest import exec_test
+import constants as cs
+import ns
 
-def test(q, bus, conn, stream):
+def test_network_error(q, bus, conn, stream):
     conn.Connect()
-    q.expect('dbus-signal', signal='StatusChanged', args=[1, 1])
-    q.expect('dbus-signal', signal='StatusChanged', args=[2, 2])
+    q.expect('dbus-signal', signal='StatusChanged',
+        args=[cs.CONN_STATUS_CONNECTING, cs.CSR_REQUESTED])
 
-if __name__ == '__main__':
-    exec_test(test, {'port': dbus.UInt32(4243)})
+    q.expect('dbus-signal', signal='StatusChanged',
+        args=[cs.CONN_STATUS_DISCONNECTED, cs.CSR_NETWORK_ERROR])
+
+def test_conflict_after_connect(q, bus, conn, stream):
+    conn.Connect()
+    q.expect('dbus-signal', signal='StatusChanged',
+        args=[cs.CONN_STATUS_CONNECTED, cs.CSR_REQUESTED])
+
+    go_away = domish.Element((xmlstream.NS_STREAMS, 'error'))
+    go_away.addElement((ns.STREAMS, 'conflict'))
+    stream.send(go_away)
 
+    q.expect('dbus-signal', signal='StatusChanged',
+        args=[cs.CONN_STATUS_DISCONNECTED, cs.CSR_NAME_IN_USE])
+
+if __name__ == '__main__':
+    exec_test(test_network_error, {'port': dbus.UInt32(4243)})
+    exec_test(test_conflict_after_connect)
diff --git a/tests/twisted/ns.py b/tests/twisted/ns.py
index cda0c0d..28aaa35 100644
--- a/tests/twisted/ns.py
+++ b/tests/twisted/ns.py
@@ -32,6 +32,7 @@ REGISTER = "jabber:iq:register"
 SI = 'http://jabber.org/protocol/si'
 SI_MULTIPLE = 'http://telepathy.freedesktop.org/xmpp/si-multiple'
 STANZA = "urn:ietf:params:xml:ns:xmpp-stanzas"
+STREAMS = "urn:ietf:params:xml:ns:xmpp-streams"
 TUBES = 'http://telepathy.freedesktop.org/xmpp/tubes'
 VCARD_TEMP = 'vcard-temp'
 X_DATA = 'jabber:x:data'
-- 
1.5.6.5




More information about the telepathy-commits mailing list