[Telepathy-commits] [telepathy-gabble/master] Twisted tests: check that Gabble can manage 2 Jabber connection at the same time
Alban Crequy
alban.crequy at collabora.co.uk
Tue Aug 19 10:52:52 PDT 2008
20080602184145-a41c0-11f6fd9dc39636b4d6362215c0c1bdce99fd4f82.gz
---
tests/twisted/Makefile.am | 1 +
tests/twisted/test-connect2.py | 87 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 88 insertions(+), 0 deletions(-)
create mode 100644 tests/twisted/test-connect2.py
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index e9f4ce3..7d4549a 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -45,6 +45,7 @@ TWISTED_TESTS = \
test-caps-hash.py \
test-connect-fail.py \
test-connect.py \
+ test-connect2.py \
test-disco.py \
test-disco-no-reply.py \
test-group-race.py \
diff --git a/tests/twisted/test-connect2.py b/tests/twisted/test-connect2.py
new file mode 100644
index 0000000..954b92c
--- /dev/null
+++ b/tests/twisted/test-connect2.py
@@ -0,0 +1,87 @@
+
+"""
+Test connecting to a server with 2 accounts. Check one account does not block
+the second account.
+"""
+
+import os
+import sys
+import dbus
+import servicetest
+
+import twisted
+
+from gabbletest import make_connection, make_stream, JabberAuthenticator
+
+def test(q, bus, conn1, conn2, stream1, stream2):
+ # Connection 1
+ conn1.Connect()
+ q.expect('dbus-signal', signal='StatusChanged', args=[1, 1])
+ q.expect('stream-authenticated')
+ q.expect('dbus-signal', signal='PresenceUpdate',
+ args=[{1L: (0L, {u'available': {}})}])
+ q.expect('dbus-signal', signal='StatusChanged', args=[0, 1])
+
+ # Connection 2
+ conn2.Connect()
+ q.expect('dbus-signal', signal='StatusChanged', args=[1, 1])
+ q.expect('stream-authenticated')
+ q.expect('dbus-signal', signal='PresenceUpdate',
+ args=[{1L: (0L, {u'available': {}})}])
+ q.expect('dbus-signal', signal='StatusChanged', args=[0, 1])
+
+
+
+
+ # Disconnection 1
+ conn1.Disconnect()
+ q.expect('dbus-signal', signal='StatusChanged', args=[2, 1])
+
+ # Disconnection 2
+ conn2.Disconnect()
+ q.expect('dbus-signal', signal='StatusChanged', args=[2, 1])
+
+ return True
+
+if __name__ == '__main__':
+ queue = servicetest.IteratingEventQueue(None)
+ queue.verbose = (
+ os.environ.get('CHECK_TWISTED_VERBOSE', '') != ''
+ or '-v' in sys.argv)
+
+ bus = dbus.SessionBus()
+
+ params = {
+ 'account': 'test1 at localhost/Resource',
+ 'password': 'pass',
+ 'resource': 'Resource',
+ 'server': 'localhost',
+ 'port': dbus.UInt32(4242),
+ }
+ conn1 = make_connection(bus, queue.append, params)
+ authenticator = JabberAuthenticator('test1', 'pass')
+ stream1 = make_stream(queue.append, authenticator, port=4242)
+
+ params = {
+ 'account': 'test2 at localhost/Resource',
+ 'password': 'pass',
+ 'resource': 'Resource',
+ 'server': 'localhost',
+ 'port': dbus.UInt32(4343),
+ }
+ conn2 = make_connection(bus, queue.append, params)
+ authenticator = JabberAuthenticator('test2', 'pass')
+ stream2 = make_stream(queue.append, authenticator, port=4343)
+
+ try:
+ test(queue, bus, conn1, conn2, stream1, stream2)
+ finally:
+ try:
+ conn1.Disconnect()
+ conn2.Disconnect()
+ # second call destroys object
+ conn1.Disconnect()
+ conn2.Disconnect()
+ except dbus.DBusException, e:
+ pass
+
--
1.5.6.3
More information about the Telepathy-commits
mailing list