refactor(db)!: finalize pooled WNDB v2 migration
This commit is contained in:
@@ -3,6 +3,7 @@ from pathlib import Path
|
||||
|
||||
from app.infra.db.postgresql import scada_assets
|
||||
from app.native.wndb.core.database import ChangeSet, sql_literal
|
||||
from app.native.wndb.gis import coordinates
|
||||
from app.native.wndb.model import controls, junctions, patterns
|
||||
|
||||
|
||||
@@ -53,6 +54,26 @@ def test_get_all_scada_info_reads_materialized_view(monkeypatch) -> None:
|
||||
assert "FROM gis.scada_devices" in statements[0]
|
||||
|
||||
|
||||
def test_get_missing_node_coord_does_not_write_default_geometry(monkeypatch) -> None:
|
||||
calls: list[tuple[str, str, tuple[str, ...]]] = []
|
||||
|
||||
def fake_try_read(name, statement, params):
|
||||
calls.append((name, statement, params))
|
||||
return None
|
||||
|
||||
monkeypatch.setattr(coordinates, "try_read", fake_try_read)
|
||||
|
||||
assert coordinates.get_node_coord("project_a", "J-1") == {"x": 0.0, "y": 0.0}
|
||||
assert calls == [
|
||||
(
|
||||
"project_a",
|
||||
"select st_astext(geom) as coord_geom "
|
||||
"from gis.node_geometries where node_id = %s",
|
||||
("J-1",),
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
def test_sql_literal_keeps_attacker_text_inside_one_postgres_literal() -> None:
|
||||
malicious = "x'); DROP SCHEMA network CASCADE; --"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user