Skip to content

Commit

Permalink
Return all additional payload frames.
Browse files Browse the repository at this point in the history
  • Loading branch information
BenediktBurger committed May 27, 2024
1 parent 17c9e2a commit a32402a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pyleco/core/internal_protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ def ask(
def interpret_rpc_response(
self, response_message: Message, extract_additional_payload: bool = False
) -> Any:
"""Retrieve the return value of a RPC response message or its binary payload."""
"""Retrieve the return value of a RPC response message or the additional payload."""
result = self.rpc_generator.get_result_from_response(response_message.payload[0])
if extract_additional_payload and result is None and len(response_message.payload) > 1:
return response_message.payload[1]
return response_message.payload[1:]
else:
return result

Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance_tests/test_director_actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,4 @@ def test_device_method_via_rpc(director: Director):
def test_binary_data_transfer(director: Director):
assert director.ask_rpc(
method="binary_method", additional_payload=[b"123"], extract_additional_payload=True
) == b"123123"
) == [b"123123"]
9 changes: 5 additions & 4 deletions tests/core/test_internal_protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,12 @@ def test_json_binary_response(self, communicator: FakeCommunicator):
message = Message(
receiver="rec",
data={"jsonrpc": "2.0", "result": None, "id": 7},
additional_payload=[b"abcd"],
)
assert (
communicator.interpret_rpc_response(message, extract_additional_payload=True) == b"abcd"
additional_payload=[b"abcd", b"efgh"],
)
assert communicator.interpret_rpc_response(message, extract_additional_payload=True) == [
b"abcd",
b"efgh",
]

def test_ignore_additional_payload_if_not_desired(self, communicator: FakeCommunicator):
message = Message(
Expand Down

0 comments on commit a32402a

Please sign in to comment.