Skip to content

Commit 7e88ecb

Browse files
Add workflow update Python wire-contract fixture
Add workflow update parity fixture
1 parent a72fa23 commit 7e88ecb

2 files changed

Lines changed: 95 additions & 0 deletions

File tree

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"schema": "durable-workflow.polyglot.control-plane-request-fixture",
3+
"version": 1,
4+
"operation": "workflow.update",
5+
"request": {
6+
"method": "POST",
7+
"path": "/workflows/wf-polyglot-231/update/quota.adjust"
8+
},
9+
"semantic_body": {
10+
"workflow_id": "wf-polyglot-231",
11+
"update_name": "quota.adjust",
12+
"wait_for": "completed",
13+
"input": [
14+
{
15+
"quota": 50,
16+
"reason": "gold-tier"
17+
}
18+
]
19+
},
20+
"cli": {
21+
"argv": {
22+
"workflow-id": "wf-polyglot-231",
23+
"update-name": "quota.adjust",
24+
"--wait": "completed",
25+
"--input": "[{\"quota\":50,\"reason\":\"gold-tier\"}]"
26+
},
27+
"expected_body": {
28+
"wait_for": "completed",
29+
"input": [
30+
{
31+
"quota": 50,
32+
"reason": "gold-tier"
33+
}
34+
]
35+
}
36+
},
37+
"sdk_python": {
38+
"args": {
39+
"workflow_id": "wf-polyglot-231",
40+
"update_name": "quota.adjust",
41+
"args": [
42+
{
43+
"quota": 50,
44+
"reason": "gold-tier"
45+
}
46+
],
47+
"wait_for": "completed"
48+
},
49+
"expected_body": {
50+
"wait_for": "completed"
51+
},
52+
"payload_envelope": {
53+
"field": "input",
54+
"codec": "avro",
55+
"decoded": [
56+
{
57+
"quota": 50,
58+
"reason": "gold-tier"
59+
}
60+
]
61+
}
62+
}
63+
}

tests/test_client.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,38 @@ async def test_update_with_request_id(self, client: Client) -> None:
690690
body = mock.call_args.kwargs.get("json") or mock.call_args[1].get("json")
691691
assert body["request_id"] == "req-123"
692692

693+
@pytest.mark.asyncio
694+
async def test_update_request_matches_polyglot_fixture(self, client: Client) -> None:
695+
fixture_path = Path(__file__).parent / "fixtures" / "control-plane" / "workflow-update-parity.json"
696+
fixture = json.loads(fixture_path.read_text())
697+
sdk = fixture["sdk_python"]
698+
expected = sdk["expected_body"]
699+
envelope_contract = sdk["payload_envelope"]
700+
701+
resp = _mock_response(200, {"outcome": "update_completed", "result": {"quota": 50}})
702+
703+
with patch.object(client._http, "request", new_callable=AsyncMock, return_value=resp) as mock:
704+
result = await client.update_workflow(**sdk["args"])
705+
706+
assert result["outcome"] == "update_completed"
707+
708+
call_args = mock.call_args
709+
assert call_args.args[0] == fixture["request"]["method"]
710+
assert call_args.args[1] == f"/api{fixture['request']['path']}"
711+
body = call_args.kwargs.get("json") or call_args[1].get("json")
712+
713+
for field, value in expected.items():
714+
assert body[field] == value
715+
716+
envelope = body[envelope_contract["field"]]
717+
assert envelope["codec"] == envelope_contract["codec"]
718+
assert serializer.decode(envelope["blob"], codec=envelope["codec"]) == envelope_contract["decoded"]
719+
720+
semantic = fixture["semantic_body"]
721+
assert sdk["args"]["workflow_id"] == semantic["workflow_id"]
722+
assert sdk["args"]["update_name"] == semantic["update_name"]
723+
assert sdk["args"]["wait_for"] == semantic["wait_for"]
724+
693725

694726
class TestGetResult:
695727
@pytest.mark.asyncio

0 commit comments

Comments
 (0)