重构爆管定位请求,移除不必要的时间参数

This commit is contained in:
2026-03-07 14:25:23 +08:00
parent 78a57f5c56
commit f5a7e5b3c9
4 changed files with 77 additions and 79 deletions
+9 -5
View File
@@ -74,7 +74,7 @@ def _load_burst_location_module():
return module
def test_run_burst_location_uses_scheme_sources_for_full_timeranges(monkeypatch, tmp_path):
def test_run_burst_location_uses_single_timerange_with_burst_source_split(monkeypatch, tmp_path):
module = _load_burst_location_module()
captured = {}
scheme_calls = []
@@ -162,14 +162,13 @@ def test_run_burst_location_uses_scheme_sources_for_full_timeranges(monkeypatch,
result = module.run_burst_location_by_network(
network="tjwater",
username="testuser",
data_source="simulation",
simulation_scheme_name="BurstSchemeA",
simulation_scheme_type="burst_analysis",
burst_leakage=10.0,
scada_burst_start=datetime(2025, 1, 1, 8, 0, 0),
scada_burst_end=datetime(2025, 1, 1, 9, 0, 0),
scada_normal_start=datetime(2025, 1, 1, 6, 0, 0),
scada_normal_end=datetime(2025, 1, 1, 7, 0, 0),
use_scada_flow=True,
)
@@ -193,9 +192,15 @@ def test_run_burst_location_uses_scheme_sources_for_full_timeranges(monkeypatch,
assert any(call["element_type"] == "link" and call["field"] == "flow" for call in scheme_calls)
assert any(call["element_type"] == "node" and call["field"] == "actual_demand" for call in scheme_calls)
assert len(realtime_calls) == 3
assert all(datetime.fromisoformat(call["start_time"]).hour == 8 for call in realtime_calls)
assert all(datetime.fromisoformat(call["end_time"]).hour == 9 for call in realtime_calls)
assert any(call["element_type"] == "node" and call["field"] == "pressure" for call in realtime_calls)
assert any(call["element_type"] == "link" and call["field"] == "flow" for call in realtime_calls)
assert any(call["element_type"] == "node" and call["field"] == "actual_demand" for call in realtime_calls)
assert result["scada_window"] == {
"burst_start": "2025-01-01T08:00:00",
"burst_end": "2025-01-01T09:00:00",
}
def test_run_burst_location_requires_simulation_scheme_name(monkeypatch, tmp_path):
@@ -217,10 +222,9 @@ def test_run_burst_location_requires_simulation_scheme_name(monkeypatch, tmp_pat
with pytest.raises(ValueError, match="simulation_scheme_name"):
module.run_burst_location_by_network(
network="tjwater",
username="testuser",
data_source="simulation",
burst_leakage=1.0,
scada_burst_start=datetime(2025, 1, 1, 8, 0, 0),
scada_burst_end=datetime(2025, 1, 1, 9, 0, 0),
scada_normal_start=datetime(2025, 1, 1, 6, 0, 0),
scada_normal_end=datetime(2025, 1, 1, 7, 0, 0),
)