diff options
author | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2011-03-15 15:19:59 +0000 |
---|---|---|
committer | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2011-03-15 15:22:52 +0000 |
commit | 67c4ee0d757d0165b9bc6f38202fe6bfee389b85 (patch) | |
tree | 1e5b55ea122687e0d1dc2820b87215e10bdb6106 | |
parent | e7fe1cceac51e7e4e9f72f74523962af4905c974 (diff) | |
download | telepathy-salut-67c4ee0d757d0165b9bc6f38202fe6bfee389b85.tar.gz |
sidecars test: added
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
-rw-r--r-- | tests/twisted/Makefile.am | 12 | ||||
-rw-r--r-- | tests/twisted/sidecars.py | 61 | ||||
-rw-r--r-- | tests/twisted/tools/exec-with-log.sh.in | 1 |
3 files changed, 73 insertions, 1 deletions
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am index 9f25976f..a4f89e9e 100644 --- a/tests/twisted/Makefile.am +++ b/tests/twisted/Makefile.am @@ -2,6 +2,7 @@ TWISTED_TESTS = TWISTED_BASIC_TESTS = \ cm/protocol.py \ + sidecars.py \ $(NULL) TWISTED_AVAHI_TESTS = \ @@ -85,8 +86,17 @@ check-twisted: exit 1;\ fi +if ENABLE_PLUGINS +PLUGINS_ENABLED_PYBOOL = True +else +PLUGINS_ENABLED_PYBOOL = False +endif + config.py: Makefile - $(AM_V_GEN)echo "PACKAGE_STRING = \"$(PACKAGE_STRING)\"" > config.py + $(AM_V_GEN) { \ + echo "PACKAGE_STRING = \"$(PACKAGE_STRING)\""; \ + echo "PLUGINS_ENABLED = $(PLUGINS_ENABLED_PYBOOL)"; \ + } > $@ BUILT_SOURCES = config.py diff --git a/tests/twisted/sidecars.py b/tests/twisted/sidecars.py new file mode 100644 index 00000000..26a7b67c --- /dev/null +++ b/tests/twisted/sidecars.py @@ -0,0 +1,61 @@ +""" +Test Salut's implementation of sidecars, using the test plugin. +""" + +from servicetest import ( + call_async, EventPattern, assertEquals + ) +from saluttest import exec_test +import constants as cs +from config import PLUGINS_ENABLED + +TEST_PLUGIN_IFACE = "org.freedesktop.Telepathy.Salut.Plugin.Test" + +if not PLUGINS_ENABLED: + print "NOTE: built without --enable-plugins, not testing plugins" + print " (but still testing failing calls to EnsureSidecar)" + +def test(q, bus, conn): + # Request a sidecar thate we support before we're connected; it should just + # wait around until we're connected. + call_async(q, conn.Future, 'EnsureSidecar', TEST_PLUGIN_IFACE) + + conn.Connect() + + if PLUGINS_ENABLED: + # Now we're connected, the call we made earlier should return. + path, props = q.expect('dbus-return', method='EnsureSidecar').value + # This sidecar doesn't even implement get_immutable_properties; it + # should just get the empty dict filled in for it. + 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)) + else: + # Only now does it fail. + q.expect('dbus-error', method='EnsureSidecar') + + # This is not a valid interface name + 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) + + call_async(q, conn, 'Disconnect') + + q.expect_many( + EventPattern('dbus-signal', signal='StatusChanged', + args=[cs.CONN_STATUS_DISCONNECTED, cs.CSR_REQUESTED]), + ) + + call_async(q, conn.Future, 'EnsureSidecar', 'zomg.what') + # With older telepathy-glib this would be DISCONNECTED; + # with newer telepathy-glib the Connection disappears from the bus + # sooner, and you get UnknownMethod or something from dbus-glib. + q.expect('dbus-error') + +if __name__ == '__main__': + exec_test(test) diff --git a/tests/twisted/tools/exec-with-log.sh.in b/tests/twisted/tools/exec-with-log.sh.in index 9f121c38..bec346ed 100644 --- a/tests/twisted/tools/exec-with-log.sh.in +++ b/tests/twisted/tools/exec-with-log.sh.in @@ -3,6 +3,7 @@ cd "@abs_top_builddir@/tests/twisted/tools" export SALUT_DEBUG=all GIBBER_DEBUG=all WOCKY_DEBUG=all +export SALUT_PLUGIN_DIR="@abs_top_builddir@/plugins/.libs" ulimit -c unlimited exec > salut-testing.log 2>&1 |