Skip to content

Commit 9cf3851

Browse files
committed
Fix boolean conversion for response_required in send_request_async method and add corresponding tests
1 parent 7688980 commit 9cf3851

File tree

3 files changed

+53
-2
lines changed

3 files changed

+53
-2
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [Unreleased]
9+
### Fixed
10+
- Fix issue with boolean `response_required` parameter in `send_request_async` method of BusinessProcess
11+
- Now converts boolean to integer (1 or 0) to ensure compatibility with IRIS API
12+
813
## [3.5.4] - 2025-11-25
914
### Added
1015
- new option for migrate `--force-local` to force local migration even if remote url is provided in the `settings.py` file

src/iop/_business_process.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,11 @@ def send_request_async(self, target: str, request: Any, description: Optional[st
8686
Raises:
8787
TypeError: If request is not of type Message or IRISObject
8888
"""
89+
# Convert boolean to int for Iris API
8990
if response_required:
90-
response_required = True
91+
response_required = 1 # type: ignore
9192
else:
92-
response_required = False
93+
response_required = 0 # type: ignore
9394
return self.iris_handle.dispatchSendRequestAsync(target, request, response_required, completion_key, description)
9495

9596
def set_timer(self, timeout: Union[int, str], completion_key: Optional[str]=None) -> None:

src/tests/test_business_process.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,51 @@ def test_async_operations(process):
4646
timeout, completion_key
4747
)
4848

49+
def test_send_request_async_response_required_boolean_conversion(process):
50+
"""Test that response_required boolean is correctly converted to int (0 or 1) for Iris API."""
51+
target = "target_service"
52+
request = SimpleMessage(integer=1, string='test')
53+
54+
# Test with response_required=True (should be converted to 1)
55+
process.send_request_async(target, request, response_required=True)
56+
args, kwargs = process.iris_handle.dispatchSendRequestAsync.call_args
57+
# args[0] = target, args[1] = request (serialized), args[2] = response_required, args[3] = completion_key, args[4] = description
58+
assert args[2] == 1, "response_required=True should be converted to 1"
59+
assert args[0] == target, "Target should be passed correctly"
60+
61+
# Reset mock
62+
process.iris_handle.reset_mock()
63+
64+
# Test with response_required=False (should be converted to 0)
65+
process.send_request_async(target, request, response_required=False)
66+
args, kwargs = process.iris_handle.dispatchSendRequestAsync.call_args
67+
assert args[2] == 0, "response_required=False should be converted to 0"
68+
assert args[0] == target, "Target should be passed correctly"
69+
70+
# Reset mock
71+
process.iris_handle.reset_mock()
72+
73+
# Test default value (should be True, converted to 1)
74+
process.send_request_async(target, request)
75+
args, kwargs = process.iris_handle.dispatchSendRequestAsync.call_args
76+
assert args[2] == 1, "Default response_required should be True (converted to 1)"
77+
78+
# Verify all parameters are passed correctly with response_required=False
79+
process.iris_handle.reset_mock()
80+
description = "Test description"
81+
completion_key = "test_key"
82+
process.send_request_async(
83+
target, request,
84+
description=description,
85+
completion_key=completion_key,
86+
response_required=False
87+
)
88+
args, kwargs = process.iris_handle.dispatchSendRequestAsync.call_args
89+
assert args[0] == target, "Target should be passed correctly"
90+
assert args[2] == 0, "response_required=False should be converted to 0"
91+
assert args[3] == completion_key, "Completion key should be passed correctly"
92+
assert args[4] == description, "Description should be passed correctly"
93+
4994
def test_persistent_properties():
5095
# Test persistent property handling
5196
class ProcessWithProperties(_BusinessProcess):

0 commit comments

Comments
 (0)