Skip to content

Commit 2071623

Browse files
Assert Python workflow history control-plane parity
Assert Python workflow history parity
1 parent 7ec6ca0 commit 2071623

2 files changed

Lines changed: 75 additions & 0 deletions

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"schema": "durable-workflow.polyglot.control-plane-request-fixture",
3+
"version": 1,
4+
"operation": "workflow.history",
5+
"request": {
6+
"method": "GET",
7+
"path": "/workflows/wf-polyglot-231/runs/run-polyglot-231/history"
8+
},
9+
"semantic_body": {
10+
"workflow_id": "wf-polyglot-231",
11+
"run_id": "run-polyglot-231"
12+
},
13+
"response_body": {
14+
"workflow_id": "wf-polyglot-231",
15+
"run_id": "run-polyglot-231",
16+
"events": [
17+
{
18+
"sequence": 1,
19+
"event_type": "WorkflowStarted",
20+
"timestamp": "2026-04-22T04:30:00Z",
21+
"payload": {
22+
"workflow_type": "orders.process",
23+
"task_queue": "orders"
24+
}
25+
},
26+
{
27+
"sequence": 2,
28+
"event_type": "ActivityScheduled",
29+
"timestamp": "2026-04-22T04:30:01Z",
30+
"payload": {
31+
"activity_type": "reserve_inventory"
32+
}
33+
}
34+
]
35+
},
36+
"cli": {
37+
"argv": {
38+
"workflow-id": "wf-polyglot-231",
39+
"run-id": "run-polyglot-231",
40+
"--json": true
41+
},
42+
"expected_query": {
43+
"wait_new_event": false
44+
}
45+
},
46+
"sdk_python": {
47+
"args": {
48+
"workflow_id": "wf-polyglot-231",
49+
"run_id": "run-polyglot-231"
50+
}
51+
}
52+
}

tests/test_client.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,29 @@ async def test_not_found(self, client: Client) -> None:
321321
await client.describe_workflow("wf-missing")
322322

323323

324+
class TestGetHistory:
325+
@pytest.mark.asyncio
326+
async def test_history_request_matches_polyglot_fixture(self, client: Client) -> None:
327+
fixture_path = Path(__file__).parent / "fixtures" / "control-plane" / "workflow-history-parity.json"
328+
fixture = json.loads(fixture_path.read_text())
329+
sdk = fixture["sdk_python"]
330+
331+
resp = _mock_response(200, fixture["response_body"])
332+
333+
with patch.object(client._http, "request", new_callable=AsyncMock, return_value=resp) as mock:
334+
history = await client.get_history(**sdk["args"])
335+
336+
call_args = mock.call_args
337+
assert call_args.args[0] == fixture["request"]["method"]
338+
assert call_args.args[1] == f"/api{fixture['request']['path']}"
339+
assert call_args.kwargs.get("json") is None
340+
341+
semantic = fixture["semantic_body"]
342+
assert sdk["args"]["workflow_id"] == semantic["workflow_id"]
343+
assert sdk["args"]["run_id"] == semantic["run_id"]
344+
assert history == fixture["response_body"]
345+
346+
324347
class TestSignalWorkflow:
325348
@pytest.mark.asyncio
326349
async def test_signal(self, client: Client) -> None:

0 commit comments

Comments
 (0)