Skip to content

Commit 1e562b9

Browse files
Assert workflow describe polyglot parity
1 parent 817e0d7 commit 1e562b9

2 files changed

Lines changed: 80 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.describe",
5+
"request": {
6+
"method": "GET",
7+
"path": "/workflows/wf-polyglot-231"
8+
},
9+
"semantic_body": {
10+
"workflow_id": "wf-polyglot-231"
11+
},
12+
"response_body": {
13+
"workflow_id": "wf-polyglot-231",
14+
"run_id": "run-polyglot-231",
15+
"workflow_type": "orders.process",
16+
"namespace": "orders-prod",
17+
"task_queue": "orders",
18+
"status": "running",
19+
"status_bucket": "active",
20+
"business_key": "order-42",
21+
"payload_codec": "avro",
22+
"memo": {
23+
"source": "polyglot-fixture"
24+
},
25+
"search_attributes": {
26+
"CustomerId": "cust-42",
27+
"Tier": "gold"
28+
},
29+
"input": [
30+
{
31+
"order_id": 42,
32+
"priority": "gold"
33+
}
34+
],
35+
"actions": {
36+
"can_query": true,
37+
"can_signal": true,
38+
"can_cancel": true
39+
}
40+
},
41+
"cli": {
42+
"argv": {
43+
"workflow-id": "wf-polyglot-231",
44+
"--json": true
45+
}
46+
},
47+
"sdk_python": {
48+
"args": {
49+
"workflow_id": "wf-polyglot-231"
50+
}
51+
}
52+
}

tests/test_client.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,34 @@ async def test_success(self, client: Client) -> None:
236236
assert isinstance(desc, WorkflowExecution)
237237
assert desc.status == "running"
238238

239+
@pytest.mark.asyncio
240+
async def test_describe_request_matches_polyglot_fixture(self, client: Client) -> None:
241+
fixture_path = Path(__file__).parent / "fixtures" / "control-plane" / "workflow-describe-parity.json"
242+
fixture = json.loads(fixture_path.read_text())
243+
sdk = fixture["sdk_python"]
244+
245+
resp = _mock_response(200, fixture["response_body"])
246+
247+
with patch.object(client._http, "request", new_callable=AsyncMock, return_value=resp) as mock:
248+
desc = await client.describe_workflow(**sdk["args"])
249+
250+
call_args = mock.call_args
251+
assert call_args.args[0] == fixture["request"]["method"]
252+
assert call_args.args[1] == f"/api{fixture['request']['path']}"
253+
assert call_args.kwargs.get("json") is None
254+
255+
semantic = fixture["semantic_body"]
256+
response = fixture["response_body"]
257+
assert sdk["args"]["workflow_id"] == semantic["workflow_id"]
258+
assert desc.workflow_id == semantic["workflow_id"]
259+
assert desc.run_id == response["run_id"]
260+
assert desc.workflow_type == response["workflow_type"]
261+
assert desc.namespace == response["namespace"]
262+
assert desc.task_queue == response["task_queue"]
263+
assert desc.status == response["status"]
264+
assert desc.payload_codec == response["payload_codec"]
265+
assert desc.input == response["input"]
266+
239267
@pytest.mark.asyncio
240268
async def test_envelope_fields(self, client: Client) -> None:
241269
resp = _mock_response(200, {

0 commit comments

Comments
 (0)