refactor(db)!: clean up business SQL access
- make realtime replacement and analysis result writes transactional\n- consolidate SCADA repositories and remove process-global project state\n- validate SCADA batches and use indexed GIS-backed business queries\n\nBREAKING CHANGE: remove the public analysis result writer and the pipeline-health network_name query parameter.
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
import asyncio
|
||||
from types import MappingProxyType
|
||||
|
||||
import pytest
|
||||
|
||||
from app.infra.db.postgresql import scada
|
||||
from app.infra.db.postgresql.scada import ScadaInfoRepository
|
||||
|
||||
|
||||
@@ -63,3 +67,24 @@ def test_get_scadas_normalizes_id_and_type():
|
||||
assert "node_id" in conn.cursor_instance.query
|
||||
assert "link_id" in conn.cursor_instance.query
|
||||
assert "FROM gis.scada_devices" in conn.cursor_instance.query
|
||||
|
||||
|
||||
def test_realtime_element_mappings_are_project_local_and_immutable(monkeypatch):
|
||||
monkeypatch.setattr(
|
||||
scada,
|
||||
"read_all",
|
||||
lambda *_args: [
|
||||
{
|
||||
"device_type": " PRESSURE ",
|
||||
"element_id": " J1 ",
|
||||
"api_query_id": " sensor-1 ",
|
||||
}
|
||||
],
|
||||
)
|
||||
|
||||
mappings = scada.load_realtime_element_mappings("project-a")
|
||||
|
||||
assert mappings.pressure == {"J1": "sensor-1"}
|
||||
assert isinstance(mappings.pressure, MappingProxyType)
|
||||
with pytest.raises(TypeError):
|
||||
mappings.pressure["J2"] = "sensor-2"
|
||||
|
||||
Reference in New Issue
Block a user