Skip to content

Commit

Permalink
Fix tests: operate window / horizon access
Browse files Browse the repository at this point in the history
  • Loading branch information
irm-codebase committed Dec 12, 2024
1 parent 66e3881 commit 166f8db
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/calliope/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class Build(ConfigBaseModel):

model_config = {
"title": "build",
"extra": "allow",
"extra": "forbid",
"revalidate_instances": "always",
}

Expand Down
4 changes: 2 additions & 2 deletions tests/common/test_model/energy_cap_per_storage_cap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ overrides:
techs.my_storage.flow_cap_per_storage_cap_min: 1
config:
build.mode: operate
solve.operate_window: 24
solve.operate_horizon: 24
solve.operate.window: 24
solve.operate.horizon: 24
4 changes: 2 additions & 2 deletions tests/common/test_model/scenarios.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,8 @@ overrides:
config.build.mode: operate
config.init.time_subset: ["2005-01-01", "2005-01-02"]
config.build.ensure_feasibility: true
config.build.operate_window: 6h
config.build.operate_horizon: 12h
config.build.operate.window: 6h
config.build.operate.horizon: 12h

investment_costs:
templates:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_backend_pyomo.py
Original file line number Diff line number Diff line change
Expand Up @@ -1648,8 +1648,8 @@ def test_add_run_mode_custom_math_before_build(self, caplog):

m = build_model(
{
"config.build.operate_window": "12H",
"config.build.operate_horizon": "12H",
"config.build.operate.window": "12H",
"config.build.operate.horizon": "12H",
},
"simple_supply,two_hours,investment_costs",
)
Expand Down
12 changes: 7 additions & 5 deletions tests/test_core_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,11 @@ def operate_model_and_log(self, request):
model.build(
force=True,
mode="operate",
operate_use_cap_results=True,
operate_window=request.param[0],
operate_horizon=request.param[1],
operate={
"use_cap_results": True,
"window": request.param[0],
"horizon": request.param[1],
},
)

with self.caplog_session(request) as caplog:
Expand Down Expand Up @@ -116,8 +118,8 @@ def test_reset_model_window(self, rerun_operate_log):
def test_end_of_horizon(self, operate_model_and_log):
"""Check that increasingly shorter time horizons are logged as model rebuilds."""
operate_model, log = operate_model_and_log
config = operate_model.backend.config.operate
if config.operate_window != config.operate_horizon:
config = operate_model.backend.config
if config.operate.window != config.operate.horizon:
assert "Reaching the end of the timeseries." in log
else:
assert "Reaching the end of the timeseries." not in log
Expand Down

0 comments on commit 166f8db

Please sign in to comment.