Skip to content

Commit 1efc927

Browse files
committed
address comments
Signed-off-by: Tim Li <[email protected]>
1 parent 2eabd54 commit 1efc927

File tree

2 files changed

+34
-25
lines changed

2 files changed

+34
-25
lines changed

cadence/client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ async def signal_workflow(
235235
workflow_id: str,
236236
run_id: str,
237237
signal_name: str,
238-
signal_input: Any = None,
238+
*signal_args: Any,
239239
) -> None:
240240
"""
241241
Send a signal to a running workflow execution.
@@ -244,16 +244,16 @@ async def signal_workflow(
244244
workflow_id: The workflow ID
245245
run_id: The run ID (can be empty string to signal current run)
246246
signal_name: Name of the signal
247-
signal_input: Input data for the signal
247+
*signal_args: Arguments to pass to the signal handler
248248
249249
Raises:
250250
ValueError: If signal encoding fails
251251
Exception: If the gRPC call fails
252252
"""
253253
signal_payload = None
254-
if signal_input is not None:
254+
if signal_args:
255255
try:
256-
signal_payload = self.data_converter.to_data([signal_input])
256+
signal_payload = self.data_converter.to_data(list[Any](signal_args))
257257
except Exception as e:
258258
raise ValueError(f"Failed to encode signal input: {e}")
259259

tests/integration_tests/test_client.py

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
)
88
from cadence.error import EntityNotExistsError
99
from tests.integration_tests.helper import CadenceHelper, DOMAIN_NAME
10-
from cadence.api.v1.service_workflow_pb2 import DescribeWorkflowExecutionRequest
10+
from cadence.api.v1.service_workflow_pb2 import (
11+
DescribeWorkflowExecutionRequest,
12+
GetWorkflowExecutionHistoryRequest,
13+
)
1114
from cadence.api.v1.common_pb2 import WorkflowExecution
1215

1316

@@ -144,15 +147,15 @@ async def test_signal_workflow(helper: CadenceHelper):
144147
This integration test verifies:
145148
1. Starting a workflow execution
146149
2. Sending a signal to the running workflow
147-
3. Signal is accepted (no errors thrown)
150+
3. Signal appears in the workflow's history
148151
"""
149152
async with helper.client() as client:
150153
workflow_type = "test-workflow-signal"
151154
task_list_name = "test-task-list-signal"
152155
workflow_id = "test-workflow-signal-789"
153156
execution_timeout = timedelta(minutes=5)
154157
signal_name = "test-signal"
155-
signal_input = {"action": "update", "value": 42}
158+
signal_arg = {"action": "update", "value": 42}
156159

157160
execution = await client.start_workflow(
158161
workflow_type,
@@ -162,25 +165,31 @@ async def test_signal_workflow(helper: CadenceHelper):
162165
)
163166

164167
await client.signal_workflow(
165-
workflow_id=execution.workflow_id,
166-
run_id=execution.run_id,
167-
signal_name=signal_name,
168-
signal_input=signal_input,
169-
)
170-
171-
describe_request = DescribeWorkflowExecutionRequest(
172-
domain=DOMAIN_NAME,
173-
workflow_execution=WorkflowExecution(
174-
workflow_id=execution.workflow_id,
175-
run_id=execution.run_id,
176-
),
168+
execution.workflow_id,
169+
execution.run_id,
170+
signal_name,
171+
signal_arg,
172+
)
173+
174+
# Fetch workflow history to verify signal was recorded
175+
history_response = await client.workflow_stub.GetWorkflowExecutionHistory(
176+
GetWorkflowExecutionHistoryRequest(
177+
domain=DOMAIN_NAME,
178+
workflow_execution=execution,
179+
skip_archival=True,
180+
)
177181
)
178182

179-
response = await client.workflow_stub.DescribeWorkflowExecution(
180-
describe_request
181-
)
183+
# Verify signal event appears in history
184+
signal_events = [
185+
event
186+
for event in history_response.history.events
187+
if event.HasField("workflow_execution_signaled_event_attributes")
188+
]
182189

190+
assert len(signal_events) == 1, "Expected exactly one signal event in history"
191+
signal_event = signal_events[0]
183192
assert (
184-
response.workflow_execution_info.workflow_execution.workflow_id
185-
== workflow_id
186-
)
193+
signal_event.workflow_execution_signaled_event_attributes.signal_name
194+
== signal_name
195+
), f"Expected signal name '{signal_name}'"

0 commit comments

Comments
 (0)