[Telepathy-commits] [telepathy-gabble/master] Twisted test connect2.py renamed to connect-twice.py
Alban Crequy
alban.crequy at collabora.co.uk
Tue Aug 19 10:52:52 PDT 2008
20080603105845-a41c0-84b2b1034d1b08a55bd969ec033c9d7b881e3d33.gz
---
tests/twisted/Makefile.am | 2 +-
tests/twisted/test-connect-twice.py | 87 +++++++++++++++++++++++++++++++++++
tests/twisted/test-connect2.py | 87 -----------------------------------
3 files changed, 88 insertions(+), 88 deletions(-)
create mode 100644 tests/twisted/test-connect-twice.py
delete mode 100644 tests/twisted/test-connect2.py
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index 7d4549a..142ac33 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -45,7 +45,7 @@ TWISTED_TESTS = \
test-caps-hash.py \
test-connect-fail.py \
test-connect.py \
- test-connect2.py \
+ test-connect-twice.py \
test-disco.py \
test-disco-no-reply.py \
test-group-race.py \
diff --git a/tests/twisted/test-connect-twice.py b/tests/twisted/test-connect-twice.py
new file mode 100644
index 0000000..954b92c
--- /dev/null
+++ b/tests/twisted/test-connect-twice.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
+
diff --git a/tests/twisted/test-connect2.py b/tests/twisted/test-connect2.py
deleted file mode 100644
index 954b92c..0000000
--- a/tests/twisted/test-connect2.py
+++ /dev/null
@@ -1,87 +0,0 @@
-
-"""
-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