feat(projects): automate project infrastructure provisioning
Generic Container CI/CD / test-build-publish (push) Successful in 1m13s
Server CI/CD v2 / build-test-publish-and-deploy (push) Successful in 1m13s

This commit is contained in:
2026-09-11 10:57:51 +08:00
parent 10a7a66a41
commit 90b02057bc
38 changed files with 2345 additions and 189 deletions
@@ -7,6 +7,7 @@ import pytest
from psycopg import connect
from app.core.config import get_pgconn_string
from app.infra.epanet import run_project_return_dict
from app.infra.db.dynamic_manager import ProjectConnectionManager
from app.infra.db.postgresql.scada import ScadaInfoRepository
from app.infra.db.timescaledb.sync_pool import timescale_connection
@@ -52,7 +53,7 @@ def test_timeseries_pool_handles_concurrent_borrows() -> None:
assert names == [PROJECT] * 64
def test_temporary_project_clone_copies_model_scada_and_views() -> None:
def test_temporary_project_clone_runs_with_network_data_only() -> None:
def counts(project: str) -> dict:
with project_connection(project) as conn, conn.cursor() as cur:
cur.execute(
@@ -61,8 +62,8 @@ def test_temporary_project_clone_copies_model_scada_and_views() -> None:
(select count(*) from network.nodes) as nodes,
(select count(*) from network.links) as links,
(select count(*) from asset.scada_devices) as scada,
(select count(*) from gis.junctions) as mv_junctions,
(select count(*) from gis.pipes) as mv_pipes
(select count(*) from gis.node_geometries) as node_geometries,
(select count(*) from gis.link_vertices) as link_vertices
"""
)
return dict(cur.fetchone())
@@ -70,7 +71,18 @@ def test_temporary_project_clone_copies_model_scada_and_views() -> None:
source_counts = counts(PROJECT)
temporary = None
with temporary_project_database(PROJECT, "clone_validation") as temporary:
assert counts(temporary) == source_counts
temporary_counts = counts(temporary)
assert temporary_counts["nodes"] == source_counts["nodes"]
assert temporary_counts["links"] == source_counts["links"]
assert temporary_counts["scada"] == 0
assert temporary_counts["node_geometries"] == 0
assert temporary_counts["link_vertices"] == 0
result = run_project_return_dict(temporary)
output = result["output"]
assert result["simulation_result"] == "successful"
assert len(output["node_results"]) == source_counts["nodes"]
assert len(output["link_results"]) == source_counts["links"]
assert temporary is not None
assert have_project(temporary) is False