feat(provenance): govern source snapshots and data inputs
This commit is contained in:
@@ -49,6 +49,54 @@ def scope_area(name: str, geometry):
|
||||
return SimpleNamespace(name=name, geometry=geometry)
|
||||
|
||||
|
||||
def governed_materialization(
|
||||
*,
|
||||
source_name: str,
|
||||
reference_layer_name: str | None,
|
||||
source_metadata: dict[str, object],
|
||||
dataset_id=None,
|
||||
) -> SimpleNamespace:
|
||||
"""Build a complete authoritative materialization for coverage tests.
|
||||
|
||||
Coverage is a production-facing statement. These fixtures must therefore
|
||||
carry the same registry, immutable snapshot, checksum and freshness state
|
||||
that a materialized official dataset needs in production.
|
||||
"""
|
||||
|
||||
source_registry_id = uuid4()
|
||||
source_snapshot_id = uuid4()
|
||||
checksum_sha256 = "a" * 64
|
||||
return SimpleNamespace(
|
||||
id=dataset_id or uuid4(),
|
||||
status="ready",
|
||||
source=source_name,
|
||||
source_name=source_name,
|
||||
reference_layer_name=reference_layer_name,
|
||||
source_metadata=dict(source_metadata),
|
||||
checksum_sha256=checksum_sha256,
|
||||
source_registry_id=source_registry_id,
|
||||
source_snapshot_id=source_snapshot_id,
|
||||
data_contract_key="geointel.vector.geojson",
|
||||
data_contract_version="1.0.0",
|
||||
validation_status="passed",
|
||||
provenance_status="complete",
|
||||
lineage_status="not_applicable",
|
||||
quarantine_status="not_quarantined",
|
||||
source_registry=SimpleNamespace(
|
||||
source_key=source_name,
|
||||
classification="authoritative",
|
||||
authority_scope_json={"scope": "coverage test"},
|
||||
usage_policy_json={},
|
||||
),
|
||||
source_snapshot=SimpleNamespace(
|
||||
source_registry_id=source_registry_id,
|
||||
checksum_sha256=checksum_sha256,
|
||||
freshness_status="current",
|
||||
ingest_status="ingested",
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def test_coverage_catalog_uses_normalized_contracts_and_does_not_change_provider_registry() -> None:
|
||||
catalog = CoverageRegistryService.catalog()
|
||||
|
||||
@@ -135,9 +183,8 @@ def test_coverage_resolver_only_reports_operational_for_materialized_ready_datas
|
||||
assert without_materialized.items[0].materialized_dataset_ids == []
|
||||
|
||||
dataset_id = uuid4()
|
||||
materialized = SimpleNamespace(
|
||||
id=dataset_id,
|
||||
status="ready",
|
||||
materialized = governed_materialization(
|
||||
dataset_id=dataset_id,
|
||||
source_name="ngi_adminvector",
|
||||
reference_layer_name="belgium_regions",
|
||||
source_metadata={"coverage_zones": ["belgium", "flanders", "wallonia", "brussels"]},
|
||||
@@ -156,9 +203,8 @@ def test_coverage_resolver_only_reports_operational_for_materialized_ready_datas
|
||||
def test_statbel_population_materialization_does_not_masquerade_as_admin_data() -> None:
|
||||
project_id = uuid4()
|
||||
statbel_id = uuid4()
|
||||
statbel = SimpleNamespace(
|
||||
id=statbel_id,
|
||||
status="ready",
|
||||
statbel = governed_materialization(
|
||||
dataset_id=statbel_id,
|
||||
source_name="statbel",
|
||||
reference_layer_name="population",
|
||||
source_metadata={"coverage_zones": ["belgium", "flanders", "wallonia", "brussels"]},
|
||||
@@ -187,9 +233,8 @@ def test_statbel_population_materialization_does_not_masquerade_as_admin_data()
|
||||
def test_bounded_api_materialization_only_covers_its_persisted_bbox() -> None:
|
||||
project_id = uuid4()
|
||||
dataset_id = uuid4()
|
||||
dataset = SimpleNamespace(
|
||||
id=dataset_id,
|
||||
status="ready",
|
||||
dataset = governed_materialization(
|
||||
dataset_id=dataset_id,
|
||||
source_name="spw_picc",
|
||||
reference_layer_name="buildings",
|
||||
source_metadata={
|
||||
@@ -230,8 +275,24 @@ def test_bounded_partition_union_can_be_operational() -> None:
|
||||
left_id = uuid4()
|
||||
right_id = uuid4()
|
||||
datasets = [
|
||||
SimpleNamespace(id=left_id, status="ready", source_name="spw_picc", reference_layer_name="buildings", source_metadata={"coverage_zones": ["wallonia"], "bbox_epsg4326": [4.50, 50.50, 4.60, 50.60]}),
|
||||
SimpleNamespace(id=right_id, status="ready", source_name="spw_picc", reference_layer_name="buildings", source_metadata={"coverage_zones": ["wallonia"], "bbox_epsg4326": [4.60, 50.50, 4.70, 50.60]}),
|
||||
governed_materialization(
|
||||
dataset_id=left_id,
|
||||
source_name="spw_picc",
|
||||
reference_layer_name="buildings",
|
||||
source_metadata={
|
||||
"coverage_zones": ["wallonia"],
|
||||
"bbox_epsg4326": [4.50, 50.50, 4.60, 50.60],
|
||||
},
|
||||
),
|
||||
governed_materialization(
|
||||
dataset_id=right_id,
|
||||
source_name="spw_picc",
|
||||
reference_layer_name="buildings",
|
||||
source_metadata={
|
||||
"coverage_zones": ["wallonia"],
|
||||
"bbox_epsg4326": [4.60, 50.50, 4.70, 50.60],
|
||||
},
|
||||
),
|
||||
]
|
||||
session = FakeSession(
|
||||
project=SimpleNamespace(id=project_id),
|
||||
@@ -252,9 +313,7 @@ def test_spw_bathymetry_materialization_is_source_specific() -> None:
|
||||
scope_area("Wallonia", box(2.5, 49.5, 6.4, 50.8)),
|
||||
]
|
||||
selection = CoverageBBox(minx=4.851, miny=50.451, maxx=4.869, maxy=50.469)
|
||||
spw_picc = SimpleNamespace(
|
||||
id=uuid4(),
|
||||
status="ready",
|
||||
spw_picc = governed_materialization(
|
||||
source_name="spw_picc",
|
||||
reference_layer_name="buildings",
|
||||
source_metadata={
|
||||
@@ -272,9 +331,8 @@ def test_spw_bathymetry_materialization_is_source_specific() -> None:
|
||||
assert without_bathymetry.items[0].materialized_dataset_ids == []
|
||||
|
||||
bathymetry_id = uuid4()
|
||||
bathymetry = SimpleNamespace(
|
||||
id=bathymetry_id,
|
||||
status="ready",
|
||||
bathymetry = governed_materialization(
|
||||
dataset_id=bathymetry_id,
|
||||
source_name="spw_bathymetry",
|
||||
reference_layer_name=None,
|
||||
source_metadata={
|
||||
@@ -309,9 +367,8 @@ def test_vha_bathymetry_profiles_are_operational_only_inside_the_persisted_selec
|
||||
assert without_profiles.items[0].source_names == ["vmm_vha_bathymetry_profiles"]
|
||||
|
||||
profile_id = uuid4()
|
||||
profiles = SimpleNamespace(
|
||||
id=profile_id,
|
||||
status="ready",
|
||||
profiles = governed_materialization(
|
||||
dataset_id=profile_id,
|
||||
source_name="vmm_vha_bathymetry_profiles",
|
||||
reference_layer_name="bathymetry_profile_points",
|
||||
source_metadata={
|
||||
@@ -360,9 +417,8 @@ def test_flemish_materialization_is_theme_specific() -> None:
|
||||
project_id = uuid4()
|
||||
project = SimpleNamespace(id=project_id)
|
||||
orthophoto_id = uuid4()
|
||||
orthophoto = SimpleNamespace(
|
||||
id=orthophoto_id,
|
||||
status="ready",
|
||||
orthophoto = governed_materialization(
|
||||
dataset_id=orthophoto_id,
|
||||
source_name="digitaal_vlaanderen_orthophoto",
|
||||
reference_layer_name="orthophoto",
|
||||
source_metadata={"coverage_zones": ["flanders"]},
|
||||
@@ -429,5 +485,5 @@ def test_frontend_prefers_materialized_national_workspace_and_resolves_drawn_bbo
|
||||
assert "externalApi.resolveCoverage" in coverage_hook
|
||||
assert "coverage.outside_supported_scope" in map_workspace
|
||||
assert "coverageStatusLabel" in map_workspace
|
||||
assert "coverageSelectionAvailable" in map_workspace
|
||||
assert "activeThemeSupportsCurrentSelection" in map_workspace
|
||||
assert "activeThemeAvailable && !regionalPartitionedThemeActive" in map_workspace
|
||||
|
||||
Reference in New Issue
Block a user