[telepathy-gabble/master] Partly disable sidecar test with --disable-plugins

Will Thompson will.thompson at collabora.co.uk
Thu Nov 26 09:19:20 PST 2009


---
 tests/twisted/Makefile.am |    7 +++
 tests/twisted/sidecars.py |  110 +++++++++++++++++++++++++-------------------
 2 files changed, 69 insertions(+), 48 deletions(-)

diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index 0fcf98c..2288254 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -190,10 +190,17 @@ else
 DEBUGGING_PYBOOL = False
 endif
 
+if ENABLE_PLUGINS
+PLUGINS_ENABLED_PYBOOL = True
+else
+PLUGINS_ENABLED_PYBOOL = False
+endif
+
 config.py: Makefile
 	$(AM_V_GEN) { \
 		echo "PACKAGE_STRING = \"$(PACKAGE_STRING)\""; \
 		echo "DEBUGGING = $(DEBUGGING_PYBOOL)"; \
+		echo "PLUGINS_ENABLED = $(PLUGINS_ENABLED_PYBOOL)"; \
 	} > $@
 
 BUILT_SOURCES = config.py
diff --git a/tests/twisted/sidecars.py b/tests/twisted/sidecars.py
index 0141fe3..14238eb 100644
--- a/tests/twisted/sidecars.py
+++ b/tests/twisted/sidecars.py
@@ -7,9 +7,14 @@ from servicetest import (
     )
 from gabbletest import exec_test, send_error_reply, acknowledge_iq, sync_stream
 import constants as cs
+from config import PLUGINS_ENABLED
 
 TEST_PLUGIN_IFACE = "org.freedesktop.Telepathy.Gabble.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, stream):
     # Request a sidecar thate we support before we're connected; it should just
     # wait around until we're connected.
@@ -19,15 +24,19 @@ def test(q, bus, conn, stream):
     q.expect('dbus-signal', signal='StatusChanged',
             args=[cs.CONN_STATUS_CONNECTED, cs.CSR_REQUESTED])
 
-    # 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)
+    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))
+        # 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')
@@ -37,46 +46,51 @@ def test(q, bus, conn, stream):
     call_async(q, conn.Future, 'EnsureSidecar', 'unsupported.sidecar')
     q.expect('dbus-error', name=cs.NOT_IMPLEMENTED)
 
-    # 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)
-
-    # This sidecar sends a stanza, and waits for a reply, before being created.
-    pattern = EventPattern('stream-iq', to='sidecar.example.com',
-        query_ns='http://example.com/sidecar')
-    call_async(q, conn.Future, 'EnsureSidecar', TEST_PLUGIN_IFACE + ".IQ")
-    e = q.expect_many(pattern)[0]
-
-    sync_dbus(bus, q, conn)
-
-    # If the server says no, EnsureSidecar should fail.
-    send_error_reply(stream, e.stanza)
-    q.expect('dbus-error', method='EnsureSidecar', name=cs.NOT_AVAILABLE)
-
-    # Let's try again. The plugin should get a chance to ping the server again.
-    call_async(q, conn.Future, 'EnsureSidecar', TEST_PLUGIN_IFACE + ".IQ")
-    e = q.expect_many(pattern)[0]
-
-    # The server said yes, so we should get a sidecar back!
-    acknowledge_iq(stream, e.stanza)
-    q.expect('dbus-return', method='EnsureSidecar')
-
-    # If we ask again once the plugin has been created, it should return at
-    # once without any more network traffic.
-    q.forbid_events([pattern])
-    conn.Future.EnsureSidecar(TEST_PLUGIN_IFACE + ".IQ")
-    sync_stream(q, stream)
-
-    # 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.
+    if PLUGINS_ENABLED:
+        # 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)
+
+        # This sidecar sends a stanza, and waits for a reply, before being
+        # created.
+        pattern = EventPattern('stream-iq', to='sidecar.example.com',
+            query_ns='http://example.com/sidecar')
+        call_async(q, conn.Future, 'EnsureSidecar', TEST_PLUGIN_IFACE + ".IQ")
+        e = q.expect_many(pattern)[0]
+
+        sync_dbus(bus, q, conn)
+
+        # If the server says no, EnsureSidecar should fail.
+        send_error_reply(stream, e.stanza)
+        q.expect('dbus-error', method='EnsureSidecar', name=cs.NOT_AVAILABLE)
+
+        # Let's try again. The plugin should get a chance to ping the server
+        # again.
+        call_async(q, conn.Future, 'EnsureSidecar', TEST_PLUGIN_IFACE + ".IQ")
+        e = q.expect_many(pattern)[0]
+
+        # The server said yes, so we should get a sidecar back!
+        acknowledge_iq(stream, e.stanza)
+        q.expect('dbus-return', method='EnsureSidecar')
+
+        # If we ask again once the plugin has been created, it should return at
+        # once without any more network traffic.
+        q.forbid_events([pattern])
+        conn.Future.EnsureSidecar(TEST_PLUGIN_IFACE + ".IQ")
+        sync_stream(q, stream)
+
+        # 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')
 
-- 
1.5.6.5




More information about the telepathy-commits mailing list