[telepathy-gabble/master] Test making two connections to the same account
Will Thompson
will.thompson at collabora.co.uk
Thu May 14 03:34:20 PDT 2009
This checks that Gabble correctly picks a random resource.
---
tests/twisted/Makefile.am | 1 +
.../connect/multiple-times-to-same-account.py | 50 ++++++++++++++++++++
2 files changed, 51 insertions(+), 0 deletions(-)
create mode 100644 tests/twisted/connect/multiple-times-to-same-account.py
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index 45b30c0..ec781a4 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -110,6 +110,7 @@ TWISTED_TESTS = \
test-caps-hash.py \
test-caps-tubes.py \
caps_helper.py \
+ connect/multiple-times-to-same-account.py \
connect/test-fail.py \
connect/test-success.py \
connect/test-twice.py \
diff --git a/tests/twisted/connect/multiple-times-to-same-account.py b/tests/twisted/connect/multiple-times-to-same-account.py
new file mode 100644
index 0000000..ed8a346
--- /dev/null
+++ b/tests/twisted/connect/multiple-times-to-same-account.py
@@ -0,0 +1,50 @@
+"""
+Tests making two connections to the same account, to see if Gabble correctly
+picks random resources when none has been specified. (If they get the same
+resource, the second call to RequestConnection will fail, since they'll try to
+have the same object path.
+"""
+
+import dbus
+
+from servicetest import tp_name_prefix, tp_path_prefix, wrap_connection
+
+if __name__ == '__main__':
+ bus = dbus.SessionBus()
+
+ name = 'gabble'
+ proto = 'jabber'
+
+ cm = bus.get_object(
+ tp_name_prefix + '.ConnectionManager.%s' % name,
+ tp_path_prefix + '/ConnectionManager/%s' % name)
+ cm_iface = dbus.Interface(cm, tp_name_prefix + '.ConnectionManager')
+
+ params = {
+ 'account': 'test at localhost',
+ 'password': 'pass',
+ 'server': 'localhost',
+ 'port': dbus.UInt32(4242),
+ }
+
+ # Create two connections with the same account and no specified resource.
+ connection_name, connection_path = cm_iface.RequestConnection(
+ proto, params)
+ conn1 = wrap_connection(bus.get_object(connection_name, connection_path))
+
+ connection_name, connection_path = cm_iface.RequestConnection(
+ proto, params)
+ conn2 = wrap_connection(bus.get_object(connection_name, connection_path))
+
+ # Cool. Let's get rid of them.
+ try:
+ conn1.Connect()
+ conn1.Disconnect()
+ except dbus.DBusException, e:
+ pass
+
+ try:
+ conn2.Connect()
+ conn2.Disconnect()
+ except dbus.DBusException, e:
+ pass
--
1.5.6.5
More information about the telepathy-commits
mailing list