Skip to content

Commit d8deb06

Browse files
TD-P004: sdk-python missing schedule.history polyglot parity slice (#39)
1 parent 95739f8 commit d8deb06

2 files changed

Lines changed: 51 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
### Changed
10+
- `tests/test_client.py` now closes the `schedule.history` polyglot
11+
parity slice. `test_get_schedule_history_matches_polyglot_fixture`
12+
asserts the full decoded payload envelope per event (`id`,
13+
`recorded_at`, `payload`, plus the workflow attribution fields)
14+
so the Python parity check covers the same wire content the CLI
15+
parity check covers when it asserts the printed JSON envelope
16+
matches the shared fixture's `response_body`. A companion
17+
`test_iter_schedule_history_walks_polyglot_fixture` exercises
18+
`Client.iter_schedule_history` against the shared fixture to lock
19+
in the cursor-advance semantics across pages.
20+
921
### Notes
1022
- Production-readiness validation is in progress for the first
1123
`1.0.0` release candidate. The 0.4.x line is feature-complete for

tests/test_client.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1885,6 +1885,45 @@ async def test_get_schedule_history_matches_polyglot_fixture(self, client: Clien
18851885
assert matching[0].workflow_instance_id == expected_refs["workflow_instance_id"]
18861886
assert matching[0].workflow_run_id == expected_refs["workflow_run_id"]
18871887

1888+
wire_events = fixture["response_body"]["events"]
1889+
assert len(page.events) == len(wire_events)
1890+
for parsed, wire in zip(page.events, wire_events):
1891+
assert parsed.id == wire["id"]
1892+
assert parsed.sequence == wire["sequence"]
1893+
assert parsed.event_type == wire["event_type"]
1894+
assert parsed.recorded_at == wire["recorded_at"]
1895+
assert parsed.workflow_instance_id == wire["workflow_instance_id"]
1896+
assert parsed.workflow_run_id == wire["workflow_run_id"]
1897+
assert parsed.payload == wire["payload"]
1898+
1899+
@pytest.mark.asyncio
1900+
async def test_iter_schedule_history_walks_polyglot_fixture(self, client: Client) -> None:
1901+
fixture_path = Path(__file__).parent / "fixtures" / "control-plane" / "schedule-history-parity.json"
1902+
fixture = json.loads(fixture_path.read_text())
1903+
sdk = fixture["sdk_python"]
1904+
wire_events = fixture["response_body"]["events"]
1905+
1906+
first_page = dict(fixture["response_body"])
1907+
last_sequence = wire_events[-1]["sequence"]
1908+
terminal_page = {
1909+
"schedule_id": fixture["response_body"]["schedule_id"],
1910+
"namespace": fixture["response_body"].get("namespace"),
1911+
"events": [],
1912+
"has_more": False,
1913+
"next_cursor": None,
1914+
}
1915+
responses = [_mock_response(200, first_page), _mock_response(200, terminal_page)]
1916+
1917+
mock = AsyncMock(side_effect=responses)
1918+
with patch.object(client._http, "request", new=mock):
1919+
collected = [event async for event in client.iter_schedule_history(**sdk["args"])]
1920+
1921+
assert [event.sequence for event in collected] == [event["sequence"] for event in wire_events]
1922+
assert [event.event_type for event in collected] == [event["event_type"] for event in wire_events]
1923+
assert mock.call_count == 2
1924+
second_path = mock.call_args_list[1].args[1]
1925+
assert f"after_sequence={last_sequence}" in second_path
1926+
18881927
@staticmethod
18891928
def _schedule_spec(data: dict) -> ScheduleSpec:
18901929
return ScheduleSpec(

0 commit comments

Comments
 (0)