Accept official Statbel archive member layout
This commit is contained in:
@@ -107,6 +107,7 @@ def geometry_archive(
|
|||||||
date: str = "2025-01-01",
|
date: str = "2025-01-01",
|
||||||
municipality_mismatch: bool = False,
|
municipality_mismatch: bool = False,
|
||||||
repairable_invalid: bool = False,
|
repairable_invalid: bool = False,
|
||||||
|
include_crs_token_in_member: bool = True,
|
||||||
) -> bytes:
|
) -> bytes:
|
||||||
payload = {
|
payload = {
|
||||||
"type": "FeatureCollection",
|
"type": "FeatureCollection",
|
||||||
@@ -133,10 +134,14 @@ def geometry_archive(
|
|||||||
}
|
}
|
||||||
payload["features"][0]["properties"]["ms_area_ha"] = 2.0
|
payload["features"][0]["properties"]["ms_area_ha"] = 2.0
|
||||||
buffer = io.BytesIO()
|
buffer = io.BytesIO()
|
||||||
|
member_stem = (
|
||||||
|
"sh_statbel_statistical_sectors_31370_20250101"
|
||||||
|
if include_crs_token_in_member
|
||||||
|
else "sh_statbel_statistical_sectors_20250101"
|
||||||
|
)
|
||||||
with zipfile.ZipFile(buffer, "w", compression=zipfile.ZIP_DEFLATED) as archive:
|
with zipfile.ZipFile(buffer, "w", compression=zipfile.ZIP_DEFLATED) as archive:
|
||||||
archive.writestr(
|
archive.writestr(
|
||||||
"sh_statbel_statistical_sectors_31370_20250101.geojson/"
|
f"{member_stem}.geojson/{member_stem}.geojson",
|
||||||
"sh_statbel_statistical_sectors_31370_20250101.geojson",
|
|
||||||
json.dumps(payload),
|
json.dumps(payload),
|
||||||
)
|
)
|
||||||
return buffer.getvalue()
|
return buffer.getvalue()
|
||||||
@@ -225,6 +230,18 @@ def test_preflight_supports_the_complete_national_scope() -> None:
|
|||||||
assert accounting["accounted_population_total"] == 243
|
assert accounting["accounted_population_total"] == 243
|
||||||
|
|
||||||
|
|
||||||
|
def test_preflight_accepts_real_archive_member_without_repeated_crs_token(tmp_path: Path) -> None:
|
||||||
|
result = validate(
|
||||||
|
tmp_path,
|
||||||
|
geometry_content=geometry_archive(include_crs_token_in_member=False),
|
||||||
|
)
|
||||||
|
|
||||||
|
assert result.manifest["status"] == "passed"
|
||||||
|
assert result.manifest["artifacts"]["geometry"]["member"].endswith(
|
||||||
|
"/sh_statbel_statistical_sectors_20250101.geojson"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_national_preflight_rejects_an_unscoped_baseline(tmp_path: Path) -> None:
|
def test_national_preflight_rejects_an_unscoped_baseline(tmp_path: Path) -> None:
|
||||||
with pytest.raises(PREFLIGHT.StatbelPreflightError) as exc_info:
|
with pytest.raises(PREFLIGHT.StatbelPreflightError) as exc_info:
|
||||||
PREFLIGHT.validate_statbel_release(
|
PREFLIGHT.validate_statbel_release(
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ POPULATION_MEMBER_PATTERN = re.compile(
|
|||||||
re.IGNORECASE,
|
re.IGNORECASE,
|
||||||
)
|
)
|
||||||
GEOMETRY_MEMBER_PATTERN = re.compile(
|
GEOMETRY_MEMBER_PATTERN = re.compile(
|
||||||
r"^sh_statbel_statistical_sectors_31370_(20[0-9]{2})0101\.geojson$",
|
r"^sh_statbel_statistical_sectors_(?:31370_)?(20[0-9]{2})0101\.geojson$",
|
||||||
re.IGNORECASE,
|
re.IGNORECASE,
|
||||||
)
|
)
|
||||||
POPULATION_SOURCE_PATTERN = re.compile(
|
POPULATION_SOURCE_PATTERN = re.compile(
|
||||||
|
|||||||
Reference in New Issue
Block a user