From 02c4fc2285e0b2939cdc52fc6a426b6067add7c0 Mon Sep 17 00:00:00 2001 From: Chris B Chamberlain Date: Fri, 26 Jun 2026 13:55:07 +1200 Subject: [PATCH] test: run the SDL parity gate as a CI test (covers schema_parity tool) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tools/schema_parity.py (the Graphene→Strawberry SDL byte-parity gate) ran as a standalone script, so it sat at 0% coverage and dragged the migration's codecov patch/project just under the auto threshold on promote PR #97. Wrap it in tests/test_sdl_parity.py — happy path (diff()=='' , main()==0) and a drift case (different baseline → non-empty diff, main()==1). Bonus: the SDL parity gate is now a permanent CI test, not a manual invocation. schema_parity.py 0% → 100%; package coverage 96% → 98%. --- tests/test_sdl_parity.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/test_sdl_parity.py diff --git a/tests/test_sdl_parity.py b/tests/test_sdl_parity.py new file mode 100644 index 0000000..77f8ccd --- /dev/null +++ b/tests/test_sdl_parity.py @@ -0,0 +1,23 @@ +"""Run the SDL parity gate as a real test. + +``tools/schema_parity.py`` asserts the Strawberry schema is byte-identical (order-insensitive) +to the frozen ``schema.legacy.graphql`` baseline. It was a standalone script; running it here +makes it a permanent CI gate (and covers the tool). +""" + +from solvis_graphql_api.tools import schema_parity + + +def test_sdl_parity_matches_legacy_baseline(): + # the migrated Strawberry SDL must still equal the frozen graphene baseline + assert schema_parity.diff() == "" + assert schema_parity.main() == 0 + + +def test_sdl_parity_reports_drift(tmp_path, monkeypatch): + # point the baseline at a different (valid) SDL → the gate must flag the drift + bad_baseline = tmp_path / "baseline.graphql" + bad_baseline.write_text("type Query { somethingCompletelyDifferent: String }") + monkeypatch.setattr(schema_parity, "BASELINE", bad_baseline) + assert schema_parity.diff() # non-empty unified diff + assert schema_parity.main() == 1