fix(platform): govern geospatial analysis and raster handoffs
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
from pathlib import Path
|
||||
from uuid import uuid4
|
||||
|
||||
@@ -187,23 +188,31 @@ def test_dataset_upload_persists_vector_features(monkeypatch, tmp_path) -> None:
|
||||
filename = "reference.geojson"
|
||||
content_type = "application/geo+json"
|
||||
|
||||
async def read(self) -> bytes:
|
||||
def __init__(self) -> None:
|
||||
import json
|
||||
|
||||
return json.dumps(payload).encode("utf-8")
|
||||
self._content = json.dumps(payload).encode("utf-8")
|
||||
|
||||
async def read(self, size: int) -> bytes:
|
||||
chunk, self._content = self._content[:size], self._content[size:]
|
||||
return chunk
|
||||
|
||||
storage_path = tmp_path / "reference.geojson"
|
||||
storage_path.write_text("{}", encoding="utf-8")
|
||||
monkeypatch.setattr(
|
||||
"app.services.dataset_service.StorageService.persist_dataset_file",
|
||||
lambda **_kwargs: {
|
||||
storage_path.write_text(json.dumps(payload), encoding="utf-8")
|
||||
|
||||
async def persist_upload_file(**_kwargs):
|
||||
return {
|
||||
"storage_path": str(storage_path),
|
||||
"original_filename": "reference.geojson",
|
||||
"stored_filename": "reference.geojson",
|
||||
"content_type": "application/geo+json",
|
||||
"size_bytes": 2,
|
||||
"size_bytes": storage_path.stat().st_size,
|
||||
"checksum_sha256": "0" * 64,
|
||||
},
|
||||
}
|
||||
|
||||
monkeypatch.setattr(
|
||||
"app.services.dataset_service.StorageService.persist_upload_file",
|
||||
persist_upload_file,
|
||||
)
|
||||
|
||||
result = asyncio.run(
|
||||
@@ -236,19 +245,28 @@ def test_dataset_upload_rolls_back_dataset_and_file_when_vector_indexing_fails(m
|
||||
filename = "invalid.geojson"
|
||||
content_type = "application/geo+json"
|
||||
|
||||
async def read(self) -> bytes:
|
||||
return b'{"type":"FeatureCollection","features":[]}'
|
||||
def __init__(self) -> None:
|
||||
self._content = b'{"type":"FeatureCollection","features":[]}'
|
||||
|
||||
monkeypatch.setattr(
|
||||
"app.services.dataset_service.StorageService.persist_dataset_file",
|
||||
lambda **_kwargs: {
|
||||
async def read(self, size: int) -> bytes:
|
||||
chunk, self._content = self._content[:size], self._content[size:]
|
||||
return chunk
|
||||
|
||||
storage_path.write_text('{"type":"FeatureCollection","features":[]}', encoding="utf-8")
|
||||
|
||||
async def persist_upload_file(**_kwargs):
|
||||
return {
|
||||
"storage_path": str(storage_path),
|
||||
"original_filename": "invalid.geojson",
|
||||
"stored_filename": "invalid.geojson",
|
||||
"content_type": "application/geo+json",
|
||||
"size_bytes": 2,
|
||||
"size_bytes": storage_path.stat().st_size,
|
||||
"checksum_sha256": "0" * 64,
|
||||
},
|
||||
}
|
||||
|
||||
monkeypatch.setattr(
|
||||
"app.services.dataset_service.StorageService.persist_upload_file",
|
||||
persist_upload_file,
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
VectorFeatureService,
|
||||
|
||||
Reference in New Issue
Block a user