[telepathy-gabble/master] Test sidecar support using test plugin
Will Thompson
will.thompson at collabora.co.uk
Tue Nov 17 03:55:59 PST 2009
---
tests/twisted/Makefile.am | 5 ++-
tests/twisted/servicetest.py | 1 +
tests/twisted/sidecars.py | 62 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 66 insertions(+), 2 deletions(-)
create mode 100644 tests/twisted/sidecars.py
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index d4ed5c3..e6a0f6b 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -148,8 +148,9 @@ TWISTED_TESTS = \
test-fallback-socks5-proxy.py \
test-register.py \
test-set-status-idempotence.py \
- test-location.py \
- pubsub.py
+ test-location.py \
+ pubsub.py \
+ sidecars.py
TESTS =
diff --git a/tests/twisted/servicetest.py b/tests/twisted/servicetest.py
index d61b55b..3a9615d 100644
--- a/tests/twisted/servicetest.py
+++ b/tests/twisted/servicetest.py
@@ -338,6 +338,7 @@ def wrap_connection(conn):
[('Peer', 'org.freedesktop.DBus.Peer'),
('ContactCapabilities', cs.CONN_IFACE_CONTACT_CAPS),
('Location', cs.CONN_IFACE_LOCATION),
+ ('Future', tp_name_prefix + '.Connection.FUTURE'),
]))
def wrap_channel(chan, type_, extra=None):
diff --git a/tests/twisted/sidecars.py b/tests/twisted/sidecars.py
new file mode 100644
index 0000000..2502c17
--- /dev/null
+++ b/tests/twisted/sidecars.py
@@ -0,0 +1,62 @@
+"""
+Test Gabble's implementation of sidecars, using the test plugin.
+"""
+
+from servicetest import call_async, EventPattern, assertEquals, assertContains
+from gabbletest import exec_test
+import constants as cs
+
+TEST_PLUGIN_IFACE = "org.freedesktop.Telepathy.Gabble.Plugin.Test"
+
+def test(q, bus, conn, stream):
+ conn.Connect()
+ q.expect('dbus-signal', signal='StatusChanged',
+ args=[cs.CONN_STATUS_CONNECTED, cs.CSR_REQUESTED])
+
+ call_async(q, conn.Future, 'EnsureSidecar', 'not an interface')
+ q.expect('dbus-error', name=cs.INVALID_ARGUMENT)
+
+ # The test plugin makes no reference to this interface.
+ call_async(q, conn.Future, 'EnsureSidecar', 'unsupported.sidecar')
+ q.expect('dbus-error', name=cs.NOT_IMPLEMENTED)
+
+ # This sidecar doesn't even implement get_immutable_properties; it should
+ # just get the empty dict filled in for it.
+ path, props = conn.Future.EnsureSidecar(TEST_PLUGIN_IFACE)
+ assertEquals({}, props)
+
+ # We should get the same sidecar if we request it again
+ path2, props2 = conn.Future.EnsureSidecar(TEST_PLUGIN_IFACE)
+ assertEquals((path, props), (path2, props2))
+
+ # This sidecar does have some properties:
+ path, props = conn.Future.EnsureSidecar(TEST_PLUGIN_IFACE + ".Props")
+ assertContains(TEST_PLUGIN_IFACE + ".Props.Greeting", props)
+
+ # The plugin claims it implements this sidecar, but actually doesn't. Check
+ # that we don't blow up (although this is no different from Gabble's
+ # perspective to creating a sidecar failing because a network service
+ # wasn't there, for instance).
+ call_async(q, conn.Future, 'EnsureSidecar', TEST_PLUGIN_IFACE + ".Buggy")
+ q.expect('dbus-error', name=cs.NOT_IMPLEMENTED)
+
+ # TODO: test ensuring a sidecar that waits for something from the network,
+ # disconnecting while it's waiting, and ensuring that nothing breaks
+ # regardless of whether the network replies before </stream:stream> or not.
+
+ call_async(q, conn, 'Disconnect')
+
+ q.expect_many(
+ EventPattern('dbus-signal', signal='StatusChanged',
+ args=[cs.CONN_STATUS_DISCONNECTED, cs.CSR_REQUESTED]),
+ EventPattern('stream-closed'),
+ )
+
+ call_async(q, conn.Future, 'EnsureSidecar', 'zomg.what')
+ q.expect('dbus-error', name=cs.DISCONNECTED)
+
+ stream.sendFooter()
+ q.expect('dbus-return', method='Disconnect')
+
+if __name__ == '__main__':
+ exec_test(test)
--
1.5.6.5
More information about the telepathy-commits
mailing list