summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2007-01-16 17:00:00 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2007-01-16 17:00:00 +0000
commite8d766e1b2d5013e3f2c0a95d43b1dcb5eb00044 (patch)
treedf3fdef2f0cf0afac3621461e7f8350413ea6fe7 /test
parentbd2baf2aad6a7f5ecf0bf7e867e74077cf733cd6 (diff)
downloaddbus-python-e8d766e1b2d5013e3f2c0a95d43b1dcb5eb00044.tar.gz
Ensure we put the right number of items in a struct or message and add test cases.
This avoids us getting kicked off the bus when trying to put the wrong number of things in a struct - this used to happen, but was masked by the fact that the tests ran with service activation, so the service was just killed and reactivated. Forthcoming changes to get_object make this automatic reactivation not happen (messages will be directed to the unique name by default, so stateful communication can work).
Diffstat (limited to 'test')
-rwxr-xr-xtest/test-standalone.py44
1 files changed, 43 insertions, 1 deletions
diff --git a/test/test-standalone.py b/test/test-standalone.py
index 3bd5716..d1c99db 100755
--- a/test/test-standalone.py
+++ b/test/test-standalone.py
@@ -1,6 +1,10 @@
#!/usr/bin/env python
-# Copyright (C) 2006 Collabora Ltd. <http://www.collabora.co.uk/>
+"""Tests that don't need an active D-Bus connection to run, but can be
+run in isolation.
+"""
+
+# Copyright (C) 2006, 2007 Collabora Ltd. <http://www.collabora.co.uk/>
#
# Licensed under the Academic Free License version 2.1
#
@@ -129,6 +133,25 @@ class TestTypes(unittest.TestCase):
class TestMessageMarshalling(unittest.TestCase):
+ def test_count(self):
+ from _dbus_bindings import SignalMessage
+ s = SignalMessage('/', 'foo.bar', 'baz')
+ try:
+ s.append('a', signature='ss')
+ except TypeError:
+ pass
+ else:
+ raise AssertionError('Appending too few things in a message '
+ 'should fail')
+ s = SignalMessage('/', 'foo.bar', 'baz')
+ try:
+ s.append('a','b','c', signature='ss')
+ except TypeError:
+ pass
+ else:
+ raise AssertionError('Appending too many things in a message '
+ 'should fail')
+
def test_append(self):
aeq = self.assertEquals
from _dbus_bindings import SignalMessage
@@ -248,6 +271,25 @@ class TestMessageMarshalling(unittest.TestCase):
s.append(MyObject())
self.assertEquals(s.get_args_list(), ['/foo', '/foo'])
+ def test_struct(self):
+ from _dbus_bindings import SignalMessage
+ s = SignalMessage('/', 'foo.bar', 'baz')
+ try:
+ s.append(('a',), signature='(ss)')
+ except TypeError:
+ pass
+ else:
+ raise AssertionError('Appending too few things in a struct '
+ 'should fail')
+ s = SignalMessage('/', 'foo.bar', 'baz')
+ try:
+ s.append(('a','b','c'), signature='(ss)')
+ except TypeError:
+ pass
+ else:
+ raise AssertionError('Appending too many things in a struct '
+ 'should fail')
+
if __name__ == '__main__':
unittest.main()