aboutsummaryrefslogtreecommitdiff
path: root/pw_rpc/py/tests/client_test.py
diff options
context:
space:
mode:
Diffstat (limited to 'pw_rpc/py/tests/client_test.py')
-rwxr-xr-xpw_rpc/py/tests/client_test.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/pw_rpc/py/tests/client_test.py b/pw_rpc/py/tests/client_test.py
index 6fcfd607f..e07125287 100755
--- a/pw_rpc/py/tests/client_test.py
+++ b/pw_rpc/py/tests/client_test.py
@@ -285,6 +285,26 @@ class ClientTest(unittest.TestCase):
method_id=method.id,
status=Status.FAILED_PRECONDITION.value))
+ def test_process_packet_non_pending_calls_response_callback(self) -> None:
+ method = self._client.method('pw.test1.PublicService.SomeUnary')
+ reply = method.response_type(payload='hello')
+
+ def response_callback(rpc: client.PendingRpc, message,
+ status: Optional[Status]) -> None:
+ self.assertEqual(
+ rpc,
+ client.PendingRpc(
+ self._client.channel(1).channel, method.service, method))
+ self.assertEqual(message, reply)
+ self.assertIs(status, Status.OK)
+
+ self._client.response_callback = response_callback
+
+ self.assertIs(
+ self._client.process_packet(
+ packets.encode_response((1, method.service, method), reply)),
+ Status.OK)
+
if __name__ == '__main__':
unittest.main()