fix(simulation): use hydraulic timestep
This commit is contained in:
@@ -19,11 +19,18 @@ def _load_simulation_module(monkeypatch):
|
||||
timezone.utc
|
||||
)
|
||||
|
||||
def parse_clock_duration_seconds(value, field_name="duration"):
|
||||
parts = [int(part) for part in value.split(":")]
|
||||
hours, minutes = parts[0], parts[1]
|
||||
seconds = parts[2] if len(parts) == 3 else 0
|
||||
return hours * 3600 + minutes * 60 + seconds
|
||||
|
||||
install_stub(
|
||||
monkeypatch,
|
||||
"app.services.time_api",
|
||||
{
|
||||
"parse_aware_time": parse_aware_time,
|
||||
"parse_clock_duration_seconds": parse_clock_duration_seconds,
|
||||
"parse_utc_time": parse_utc_time,
|
||||
},
|
||||
)
|
||||
@@ -31,6 +38,7 @@ def _load_simulation_module(monkeypatch):
|
||||
monkeypatch,
|
||||
"app.services.simulation",
|
||||
{
|
||||
"get_time": lambda name: {"HYDRAULIC TIMESTEP": "0:15:00"},
|
||||
"run_simulation": lambda **kwargs: None,
|
||||
"query_corresponding_element_id_and_query_id": lambda name: None,
|
||||
"query_corresponding_pattern_id_and_query_id": lambda name: None,
|
||||
@@ -227,6 +235,33 @@ def test_run_simulation_manually_by_date_uses_utc_aware_timestamps(monkeypatch):
|
||||
]
|
||||
|
||||
|
||||
def test_run_simulation_manually_by_date_uses_hydraulic_timestep(monkeypatch):
|
||||
module = _load_simulation_module(monkeypatch)
|
||||
captured_calls = []
|
||||
|
||||
monkeypatch.setattr(
|
||||
module.simulation,
|
||||
"get_time",
|
||||
lambda name: {"HYDRAULIC TIMESTEP": "1:00"},
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
module.simulation,
|
||||
"run_simulation",
|
||||
lambda **kwargs: captured_calls.append(kwargs),
|
||||
)
|
||||
|
||||
module.run_simulation_manually_by_date(
|
||||
"demo",
|
||||
datetime(2025, 1, 1, 16, 0, 0, tzinfo=timezone.utc),
|
||||
120,
|
||||
)
|
||||
|
||||
assert [call["modify_pattern_start_time"] for call in captured_calls] == [
|
||||
"2025-01-01T16:00:00+00:00",
|
||||
"2025-01-01T17:00:00+00:00",
|
||||
]
|
||||
|
||||
|
||||
def test_runsimulationmanuallybydate_endpoint_accepts_timezone_aware_start_time(monkeypatch):
|
||||
module = _load_simulation_module(monkeypatch)
|
||||
captured = {}
|
||||
|
||||
Reference in New Issue
Block a user