Show route metadata in fixture checks

This commit is contained in:
jwinterm
2026-07-06 03:41:26 -04:00
parent d3c287074b
commit cd60935f95
4 changed files with 23 additions and 0 deletions
+2
View File
@@ -185,6 +185,8 @@ def _cmd_fixture(args) -> int:
"AMPBROWSER_FIXTURE "
f"site={check.site_id} "
f"protocol={check.protocol} "
f"route_match={check.route_match} "
f"fixture_path={check.fixture_path} "
f"url={check.url} "
f"expected_transport={check.expected_transport} "
f"actual_transport={check.actual_transport} "
+15
View File
@@ -16,6 +16,8 @@ SUPPORTED_SCHEMAS = {"ampg.fixture-manifest.v1"}
class FixtureCheck:
site_id: str
protocol: str
route_match: str
fixture_path: str
url: str
expected_transport: str
actual_transport: str
@@ -77,6 +79,7 @@ def _check_fixture(site_id: str, fixture: Any, path: Path) -> FixtureCheck:
expected_transport = _string(checks, "transport")
expected_profile = _string(checks, "profile")
interaction = _interaction_policy(fixture)
route_metadata = _route_metadata(fixture)
route = route_url(url)
failures: list[str] = []
@@ -98,6 +101,8 @@ def _check_fixture(site_id: str, fixture: Any, path: Path) -> FixtureCheck:
return FixtureCheck(
site_id=site_id,
protocol=protocol,
route_match=route_metadata["match"],
fixture_path=route_metadata["fixture_path"],
url=route.normalized,
expected_transport=expected_transport,
actual_transport=route.transport,
@@ -140,6 +145,16 @@ def _interaction_policy(fixture: dict[str, Any]) -> dict[str, Any]:
}
def _route_metadata(fixture: dict[str, Any]) -> dict[str, str]:
raw = fixture.get("route", {})
if not isinstance(raw, dict):
raise ValueError(f"{fixture.get('protocol', 'fixture')}: route must be a table")
return {
"match": _optional_string(raw, "match", "/"),
"fixture_path": _optional_string(raw, "fixture_path", "/"),
}
def _optional_string(data: dict[str, Any], key: str, default: str) -> str:
value = data.get(key, default)
if not isinstance(value, str) or not value: