Skip to content

Commit 7ec6ca0

Browse files
Assert Python workflow terminate control-plane parity
Assert Python workflow terminate parity
1 parent 1e562b9 commit 7ec6ca0

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.terminate",
5+
"request": {
6+
"method": "POST",
7+
"path": "/workflows/wf-polyglot-231/terminate"
8+
},
9+
"semantic_body": {
10+
"workflow_id": "wf-polyglot-231",
11+
"reason": "operator forced failover"
12+
},
13+
"cli": {
14+
"argv": {
15+
"workflow-id": "wf-polyglot-231",
16+
"--reason": "operator forced failover"
17+
},
18+
"expected_body": {
19+
"reason": "operator forced failover"
20+
}
21+
},
22+
"sdk_python": {
23+
"args": {
24+
"workflow_id": "wf-polyglot-231",
25+
"reason": "operator forced failover"
26+
},
27+
"expected_body": {
28+
"reason": "operator forced failover"
29+
}
30+
}
31+
}

tests/test_client.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,25 @@ async def test_terminate(self, client: Client) -> None:
542542
call_args = mock.call_args
543543
assert "/terminate" in call_args[0][1]
544544

545+
@pytest.mark.asyncio
546+
async def test_terminate_request_matches_polyglot_fixture(self, client: Client) -> None:
547+
fixture_path = Path(__file__).parent / "fixtures" / "control-plane" / "workflow-terminate-parity.json"
548+
fixture = json.loads(fixture_path.read_text())
549+
sdk = fixture["sdk_python"]
550+
551+
resp = _mock_response(200, {"ok": True})
552+
with patch.object(client._http, "request", new_callable=AsyncMock, return_value=resp) as mock:
553+
await client.terminate_workflow(**sdk["args"])
554+
555+
call_args = mock.call_args
556+
assert call_args.args[0] == fixture["request"]["method"]
557+
assert call_args.args[1] == f"/api{fixture['request']['path']}"
558+
body = call_args.kwargs.get("json") or call_args[1].get("json")
559+
560+
assert body == sdk["expected_body"]
561+
assert body["reason"] == fixture["semantic_body"]["reason"]
562+
assert sdk["args"]["workflow_id"] == fixture["semantic_body"]["workflow_id"]
563+
545564

546565
class TestQueryWorkflow:
547566
@pytest.mark.asyncio

0 commit comments

Comments
 (0)