diff options
author | Simon McVittie <smcv@collabora.com> | 2019-09-02 13:10:30 +0100 |
---|---|---|
committer | Simon McVittie <smcv@collabora.com> | 2019-09-02 13:45:44 +0100 |
commit | e9f658d9d57b97395545c5ed2eaf9a85436f135d (patch) | |
tree | 43cd756a1b76bbede997b38c156e764cd36d0107 /test/test-service.py | |
parent | 6a4e06167279c90be6c692612ceab39674589a4d (diff) |
Add a test for NO_REPLY method calls
See https://gitlab.freedesktop.org/dbus/dbus-python/issues/26
Signed-off-by: Simon McVittie <smcv@collabora.com>
Diffstat (limited to 'test/test-service.py')
-rwxr-xr-x | test/test-service.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/test-service.py b/test/test-service.py index 4289455..2799185 100755 --- a/test/test-service.py +++ b/test/test-service.py @@ -69,6 +69,11 @@ NAME = "org.freedesktop.DBus.TestSuitePythonService" IFACE = "org.freedesktop.DBus.TestSuiteInterface" OBJECT = "/org/freedesktop/DBus/TestSuitePythonObject" +# A random string that we should not transmit on the bus as a result of +# the NO_REPLY flag +SHOULD_NOT_HAPPEN = 'a1c04a41-cf98-4923-8487-ddaeeb3f02d1' + + class RemovableObject(dbus.service.Object): # Part of test for https://bugs.freedesktop.org/show_bug.cgi?id=10457 @dbus.service.method(IFACE, in_signature='', out_signature='b') @@ -144,6 +149,8 @@ class TestObject(dbus.service.Object, TestInterface): object_path + '/Multi2') self._multi.add_to_connection(bus_name.get_bus(), object_path + '/Multi2/3') + self._times_no_reply_succeeded = 0 + self._times_no_reply_failed = 0 """ Echo whatever is sent """ @@ -341,6 +348,23 @@ class TestObject(dbus.service.Object, TestInterface): def RaiseValueError(self): raise ValueError('Wrong!') + @dbus.service.method(IFACE, in_signature='bb', out_signature='sii') + def TestNoReply(self, succeed, report): + """Callers are meant to call this with the NO_REPLY flag, + unless they call it with report=true.""" + + if report: + return ('TestNoReply report', + self._times_no_reply_succeeded, + self._times_no_reply_failed) + + if succeed: + self._times_no_reply_succeeded += 1 + return (SHOULD_NOT_HAPPEN, 0, 0) + else: + self._times_no_reply_failed += 1 + raise ValueError(SHOULD_NOT_HAPPEN) + @dbus.service.method(IFACE, in_signature='', out_signature='') def RaiseDBusExceptionNoTraceback(self): class ServerError(dbus.DBusException): |