From dcdc5c6899f29c5a53b183427367e75da3ad1425 Mon Sep 17 00:00:00 2001 From: CMGS Date: Fri, 14 Aug 2026 03:13:12 +0800 Subject: [PATCH] test(python): pin all four enum sets, and the git_branch actions in use The corpus check covered error_kind and event_kind only. git_branch_action is the one Python hardcodes as literals at four call sites, so a rename on the silkd side would have surfaced as a runtime rejection rather than a failing test - Go and Rust both pin all four. The second test drives the real verbs and asserts the actions they put on the wire are exactly the corpus set. --- sdk/python/tests/test_wire_binding.py | 43 ++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/sdk/python/tests/test_wire_binding.py b/sdk/python/tests/test_wire_binding.py index 24c2cc3..afe714e 100644 --- a/sdk/python/tests/test_wire_binding.py +++ b/sdk/python/tests/test_wire_binding.py @@ -153,7 +153,48 @@ def test_call_site_matches_fixture(monkeypatch, stem, replies, invoke): assert value == fixture[key], f"field {key!r}: {value!r} != {fixture[key]!r}" -def test_enum_error_kinds_match_corpus(): +def test_enum_value_sets_match_corpus(): enums = json.loads((FIXTURES / "enums.json").read_text()) assert set(enums["error_kind"]) == {"bad_request", "not_found", "unimplemented", "internal"} assert set(enums["event_kind"]) == {"created", "modified", "deleted", "renamed"} + assert set(enums["file_kind"]) == {"file", "dir", "symlink", "other"} + assert set(enums["git_branch_action"]) == {"list", "create", "delete", "checkout"} + + +class BranchActionConn: + """Records the action each git_branch verb puts on the wire.""" + + def __init__(self, sent): + self.sent = sent + self.action = "" + + def __enter__(self): + return self + + def __exit__(self, *exc): + pass + + def send(self, op, **fields): + self.action = fields.get("action") + self.sent.append(self.action) + + def recv(self): + if self.action == "list": + return {"type": "git_branches", "branches": [], "current": ""} + return {"type": "done"} + + def recv_until(self, *terminal): + yield self.recv() + + +def test_git_branch_actions_come_from_the_corpus(monkeypatch): + enums = json.loads((FIXTURES / "enums.json").read_text()) + sb = Sandbox(client=Client("127.0.0.1:1"), id="sb_1", token="tok", owner="127.0.0.1:1") + sent = [] + monkeypatch.setattr(sb, "_dial", lambda: BranchActionConn(sent)) + + sb.git_branches("/w") + sb.git_create_branch("/w", "b") + sb.git_delete_branch("/w", "b") + sb.git_checkout("/w", "b") + assert set(sent) == set(enums["git_branch_action"])