fix(map): reject a zones layer without a deployment section
The README documents deployment as required when zones exist, but load_map only enforced the reverse direction (deployment without zones). A map with a zones layer and no deployment now fails with MapValidationError instead of loading with unreachable deployment zones.
This commit is contained in:
@@ -131,6 +131,13 @@ def _check_deployment(
|
|||||||
deployment: dict[str, str], zones: tuple[str, ...] | None, path: Path
|
deployment: dict[str, str], zones: tuple[str, ...] | None, path: Path
|
||||||
) -> None:
|
) -> None:
|
||||||
if not deployment:
|
if not deployment:
|
||||||
|
if zones is not None:
|
||||||
|
msg = (
|
||||||
|
"zones layer declared but no deployment section (the README "
|
||||||
|
"requires deployment when zones exist: each zone letter needs "
|
||||||
|
"a side)"
|
||||||
|
)
|
||||||
|
raise MapValidationError(path, msg)
|
||||||
return
|
return
|
||||||
if zones is None:
|
if zones is None:
|
||||||
msg = "deployment declared but no zones layer"
|
msg = "deployment declared but no zones layer"
|
||||||
|
|||||||
@@ -111,6 +111,12 @@ def test_rejects_deployment_without_zone(tmp_path: Path) -> None:
|
|||||||
load_map(_write(tmp_path, body))
|
load_map(_write(tmp_path, body))
|
||||||
|
|
||||||
|
|
||||||
|
def test_rejects_zones_without_deployment(tmp_path: Path) -> None:
|
||||||
|
body = _minimal_map() + "zones: |\n ...\n .A.\n ...\n"
|
||||||
|
with pytest.raises(MapValidationError, match="no deployment section"):
|
||||||
|
load_map(_write(tmp_path, body))
|
||||||
|
|
||||||
|
|
||||||
def test_rejects_shared_deployment_zone_letter(tmp_path: Path) -> None:
|
def test_rejects_shared_deployment_zone_letter(tmp_path: Path) -> None:
|
||||||
"""Two sides bound to the same zone letter would deploy on top of each
|
"""Two sides bound to the same zone letter would deploy on top of each
|
||||||
other (build_states resets its placed set per side): a data error."""
|
other (build_states resets its placed set per side): a data error."""
|
||||||
|
|||||||
Reference in New Issue
Block a user