summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlban Crequy <alban.crequy@collabora.co.uk>2011-12-13 16:43:57 +0000
committerAlban Crequy <alban.crequy@collabora.co.uk>2012-03-27 19:47:36 +0100
commit71dcf75998ea8a332903def7b6513df5e4e6d819 (patch)
tree5ffbf4e6178011604dd4433547cac0c8a4fd76c5
parent45d81af51417a79bd2fd7c98b0980ba7e725dd5c (diff)
New test: connect/test-connection-params.py
https://bugs.freedesktop.org/show_bug.cgi?id=43828
-rw-r--r--tests/twisted/Makefile.am1
-rw-r--r--tests/twisted/connect/test-connection-params.py54
2 files changed, 55 insertions, 0 deletions
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index ed9f6d073..f8457f7a9 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -25,6 +25,7 @@ TWISTED_TESTS = \
connect/disco-no-reply.py \
connect/network-error.py \
connect/stream-closed.py \
+ connect/test-connection-params.py \
connect/test-fail.py \
connect/test-nonblocking-tls.py \
connect/test-success.py \
diff --git a/tests/twisted/connect/test-connection-params.py b/tests/twisted/connect/test-connection-params.py
new file mode 100644
index 000000000..48b504e7c
--- /dev/null
+++ b/tests/twisted/connect/test-connection-params.py
@@ -0,0 +1,54 @@
+
+"""
+Test connecting with different ContactList.DownloadAtConnection values
+"""
+
+import dbus
+
+from servicetest import EventPattern
+from gabbletest import exec_test, sync_stream, call_async
+import constants as cs
+import ns
+
+forbidden = [EventPattern('stream-iq', query_ns=ns.ROSTER)]
+
+def test_get_roster(q, bus, conn, stream):
+ # DownloadAtConnection = True, so gabble should get the roster
+ # automatically
+ q.expect('stream-iq', query_ns=ns.ROSTER)
+
+ # but calling ContactList.Download should not try and get the
+ # roster again
+ q.forbid_events(forbidden)
+ conn.ContactList.Download()
+ sync_stream(q, stream)
+ q.unforbid_events(forbidden)
+
+def test_dont_get_roster(q, bus, conn, stream):
+ # DownloadAtConnection = False, so let's make sure the roster
+ # isn't fetched automatically
+ q.forbid_events(forbidden)
+
+ conn.Connect()
+ q.expect_many(EventPattern('dbus-signal', signal='StatusChanged',
+ args=[cs.CONN_STATUS_CONNECTED, cs.CSR_REQUESTED]))
+ sync_stream(q, stream)
+ q.unforbid_events(forbidden)
+
+ # seems fine, now calling Download should try and get the roster
+ # successfully.
+ call_async(q, conn.ContactList, 'Download')
+
+ q.expect_many(EventPattern('stream-iq', query_ns=ns.ROSTER),
+ EventPattern('dbus-return', method='Download'))
+
+if __name__ == '__main__':
+ # Parameter DownloadAtConnection = True
+ exec_test(test_get_roster,
+ params={cs.CONN_IFACE_CONTACT_LIST + '.DownloadAtConnection': True})
+
+ # Parameter DownloadAtConnection = False
+ exec_test(test_dont_get_roster,
+ params={cs.CONN_IFACE_CONTACT_LIST + '.DownloadAtConnection': False},
+ do_connect=False)
+