From 997761dba8fe5fa06524deb3868f45ab3d6bc5f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Lowas-Rzechonek?= Date: Fri, 27 Dec 2019 21:51:02 +0100 Subject: [PATCH] Add unit tests for not sending reply when NO_REPLY_EXPECTED is set. fixes #25 --- test/service/test_methods.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/test/service/test_methods.py b/test/service/test_methods.py index 1d4ffef..f85f91b 100644 --- a/test/service/test_methods.py +++ b/test/service/test_methods.py @@ -1,6 +1,6 @@ from dbus_next.service import ServiceInterface, method from dbus_next.aio import MessageBus -from dbus_next import Message, MessageType, ErrorType, Variant, SignatureTree, DBusError +from dbus_next import Message, MessageType, ErrorType, Variant, SignatureTree, DBusError, MessageFlag import pytest @@ -59,14 +59,15 @@ async def test_methods(): interface = ExampleInterface('test.interface') export_path = '/test/path' - async def call(member, signature='', body=[]): + async def call(member, signature='', body=[], flags=MessageFlag.NONE): return await bus2.call( Message(destination=bus1.unique_name, path=export_path, interface=interface.name, member=member, signature=signature, - body=body)) + body=body, + flags=flags)) bus1.export(export_path, interface) @@ -107,3 +108,12 @@ async def call(member, signature='', body=[]): assert reply.message_type == MessageType.ERROR, reply.body[0] assert reply.error_name == 'test.error', reply.body[0] assert reply.body == ['an error ocurred'] + + reply = await call('ping', flags=MessageFlag.NO_REPLY_EXPECTED) + assert reply is None + + reply = await call('throws_unexpected_error', flags=MessageFlag.NO_REPLY_EXPECTED) + assert reply is None + + reply = await call('throws_dbus_error', flags=MessageFlag.NO_REPLY_EXPECTED) + assert reply is None