feat(provenance): govern source snapshots and data inputs

This commit is contained in:
Jens
2026-08-01 23:46:17 +02:00
parent cebeb5f3b4
commit 5b3c17b494
96 changed files with 20156 additions and 351 deletions
@@ -6,6 +6,7 @@ from uuid import uuid4
import pytest
from geoalchemy2.shape import to_shape
from pyproj import Transformer
from app.api.routes.qa import compare_candidate_with_reference
from app.models import Dataset, Metric, Project, QualityCheck, VectorFeature
@@ -117,6 +118,54 @@ def test_vector_feature_service_normalizes_source_z_coordinates_to_canonical_2d(
assert to_shape(persisted[0].geometry).has_z is False
def test_vector_feature_service_transforms_declared_source_crs_before_epsg4326_storage() -> None:
to_lambert = Transformer.from_crs("EPSG:4326", "EPSG:31370", always_xy=True)
x, y = to_lambert.transform(4.7, 51.1)
db = FakeSession()
persisted = VectorFeatureService.persist_geojson_features(
db=db,
dataset_id=uuid4(),
payload={
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"id": "lambert-point",
"properties": {},
"geometry": {"type": "Point", "coordinates": [x, y]},
}
],
},
source_crs="EPSG:31370",
)
geometry = to_shape(persisted[0].geometry)
assert geometry.x == pytest.approx(4.7, abs=0.000001)
assert geometry.y == pytest.approx(51.1, abs=0.000001)
def test_vector_feature_service_rejects_invalid_declared_source_crs() -> None:
with pytest.raises(Exception) as exc_info:
VectorFeatureService.persist_geojson_features(
db=FakeSession(),
dataset_id=uuid4(),
payload={
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {"type": "Point", "coordinates": [4.7, 51.1]},
}
],
},
source_crs="EPSG:not-a-crs",
)
assert getattr(exc_info.value, "code", None) == "INVALID_DATASET_CRS"
def test_dataset_upload_persists_vector_features(monkeypatch, tmp_path) -> None:
project_id = uuid4()
db = FakeSession(objects={(Project, project_id): Project(id=project_id, name="Geel")})