summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDavid Laban <david.laban@collabora.co.uk>2011-05-31 15:33:06 -0400
committerDavid Laban <david.laban@collabora.co.uk>2011-05-31 15:33:06 -0400
commitef8d5d16475dce2a82b59898615b265e57dc7422 (patch)
tree3926d7da56f01b881536cb1fdbdc20ca88c3ec33 /tests
parentcacf971a900f6d30f92540f82db9dc48261e4994 (diff)
Add test-debug.py
Copied from gabble. This also requires a config.py in BUILT_SOURCES
Diffstat (limited to 'tests')
-rw-r--r--tests/twisted/Makefile.am19
-rw-r--r--tests/twisted/test-debug.py65
2 files changed, 82 insertions, 2 deletions
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index e8528a4..816c77d 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -5,6 +5,7 @@ TWISTED_TESTS = \
test-register.py \
test-register-fail.py \
test-register-sasl.py \
+ test-debug.py \
test-handle-normalisation.py \
test-message.py \
test-self-alias.py \
@@ -16,7 +17,7 @@ TWISTED_TESTS = \
TESTS =
TESTS_ENVIRONMENT = \
- PYTHONPATH=@abs_top_srcdir@/tests/twisted
+ PYTHONPATH=@abs_top_srcdir@/tests/twisted::@abs_top_builddir@/tests/twisted
check-local: check-coding-style check-twisted
@@ -33,6 +34,20 @@ check-twisted:
TESTS_ENVIRONMENT="$(TESTS_ENVIRONMENT) $(PYTHON)" 2>&1 | \
fgrep -v -e DeprecationWarning -e DigestAuthorizer
+if ENABLE_DEBUG
+DEBUGGING_PYBOOL = True
+else
+DEBUGGING_PYBOOL = False
+endif
+
+config.py: Makefile
+ $(AM_V_GEN) { \
+ echo "PACKAGE_STRING = \"$(PACKAGE_STRING)\""; \
+ echo "DEBUGGING = $(DEBUGGING_PYBOOL)"; \
+ } > $@
+
+BUILT_SOURCES = config.py
+
EXTRA_DIST = \
$(TWISTED_TESTS) \
constants.py \
@@ -40,7 +55,7 @@ EXTRA_DIST = \
servicetest.py \
voip/voip_test.py
-CLEANFILES = rakia-[1-9]*.log *.pyc */*.pyc
+CLEANFILES = rakia-[1-9]*.log *.pyc */*.pyc config.py
check_misc_sources = $(TESTS)
diff --git a/tests/twisted/test-debug.py b/tests/twisted/test-debug.py
new file mode 100644
index 0000000..498d319
--- /dev/null
+++ b/tests/twisted/test-debug.py
@@ -0,0 +1,65 @@
+
+"""
+Test the debug message interface.
+"""
+
+import dbus
+
+from servicetest import assertEquals, sync_dbus
+from sofiatest import exec_test
+import constants as cs
+from config import DEBUGGING
+
+if not DEBUGGING:
+ print " -- Not testing debugger, built with --disable-debug"
+ raise SystemExit(77)
+
+path = '/org/freedesktop/Telepathy/debug'
+iface = 'org.freedesktop.Telepathy.Debug'
+
+def test(q, bus, conn, stream):
+ conn.Connect()
+ q.expect('dbus-signal', signal='StatusChanged', args=[0, 1])
+
+ messages = []
+
+ def new_message(timestamp, domain, level, string):
+ messages.append((timestamp, domain, level, string))
+
+ debug = bus.get_object(conn.bus_name, path)
+ debug_iface = dbus.Interface(debug, iface)
+ debug_iface.connect_to_signal('NewDebugMessage', new_message)
+ props_iface = dbus.Interface(debug, cs.PROPERTIES_IFACE)
+
+ assert len(debug_iface.GetMessages()) > 0
+
+ # Turn signalling on and generate some messages.
+
+ assert len(messages) == 0
+ assert props_iface.Get(iface, 'Enabled') == False
+ props_iface.Set(iface, 'Enabled', True)
+
+ channel_path = conn.RequestChannel(
+ cs.CHANNEL_TYPE_TEXT, cs.HT_CONTACT, conn.GetSelfHandle(), True)
+ q.expect('dbus-signal', signal='NewChannel')
+
+ assert len(messages) > 0
+
+ # Turn signalling off and check we don't get any more messages.
+
+ props_iface.Set(iface, 'Enabled', False)
+ sync_dbus(bus, q, conn)
+ snapshot = list(messages)
+
+ channel = bus.get_object(conn.bus_name, channel_path)
+ channel.Close(dbus_interface=cs.CHANNEL)
+ q.expect('dbus-signal', signal='Closed')
+
+ conn.RequestChannel(
+ cs.CHANNEL_TYPE_TEXT, cs.HT_CONTACT, conn.GetSelfHandle(), True)
+ q.expect('dbus-signal', signal='NewChannel')
+
+ assertEquals (snapshot, messages)
+
+if __name__ == '__main__':
+ exec_test(test)