Skip to content

Commit 76df9be

Browse files
Assert Python workflow cancel parity fixture
1 parent f4fa750 commit 76df9be

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"schema": "durable-workflow.polyglot.control-plane-request-fixture",
3+
"version": 1,
4+
"operation": "workflow.cancel",
5+
"request": {
6+
"method": "POST",
7+
"path": "/workflows/wf-polyglot-231/cancel"
8+
},
9+
"semantic_body": {
10+
"workflow_id": "wf-polyglot-231",
11+
"reason": "customer requested refund"
12+
},
13+
"cli": {
14+
"argv": {
15+
"workflow-id": "wf-polyglot-231",
16+
"--reason": "customer requested refund"
17+
},
18+
"expected_body": {
19+
"reason": "customer requested refund"
20+
}
21+
},
22+
"sdk_python": {
23+
"args": {
24+
"workflow_id": "wf-polyglot-231",
25+
"reason": "customer requested refund"
26+
},
27+
"expected_body": {
28+
"reason": "customer requested refund"
29+
}
30+
}
31+
}

tests/test_client.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,25 @@ async def test_cancel(self, client: Client) -> None:
346346
body = call_args.kwargs.get("json") or call_args[1].get("json")
347347
assert body["reason"] == "test"
348348

349+
@pytest.mark.asyncio
350+
async def test_cancel_request_matches_polyglot_fixture(self, client: Client) -> None:
351+
fixture_path = Path(__file__).parent / "fixtures" / "control-plane" / "workflow-cancel-parity.json"
352+
fixture = json.loads(fixture_path.read_text())
353+
sdk = fixture["sdk_python"]
354+
355+
resp = _mock_response(200, {"ok": True})
356+
with patch.object(client._http, "request", new_callable=AsyncMock, return_value=resp) as mock:
357+
await client.cancel_workflow(**sdk["args"])
358+
359+
call_args = mock.call_args
360+
assert call_args.args[0] == fixture["request"]["method"]
361+
assert call_args.args[1] == f"/api{fixture['request']['path']}"
362+
body = call_args.kwargs.get("json") or call_args[1].get("json")
363+
364+
assert body == sdk["expected_body"]
365+
assert body["reason"] == fixture["semantic_body"]["reason"]
366+
assert sdk["args"]["workflow_id"] == fixture["semantic_body"]["workflow_id"]
367+
349368

350369
class TestTerminateWorkflow:
351370
@pytest.mark.asyncio

0 commit comments

Comments
 (0)