Skip to content

Commit b76e0c2

Browse files
committed
Fix tests for microgrid configs
To account for changes in the previous commits. Signed-off-by: cwasicki <[email protected]>
1 parent 3959b2e commit b76e0c2

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

tests/test_config.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
VALID_CONFIG: dict[str, dict[str, Any]] = {
1616
"1": {
17-
"meta": {"name": "Test Grid", "gid": 1},
17+
"meta": {"name": "Test Grid", "gid": 1, "microgrid_id": 1},
1818
"ctype": {
1919
"pv": {"meter": [101, 102], "formula": {"AC_ACTIVE_POWER": "#12+#23"}},
2020
"battery": {
@@ -52,21 +52,18 @@ def test_is_valid_type() -> None:
5252

5353
def test_component_type_config_cids() -> None:
5454
"""Test the retrieval of component IDs for various configurations."""
55-
config = ComponentTypeConfig(component_type="pv", meter=[1, 2, 3])
55+
config = ComponentTypeConfig(inverter=[1, 2, 3])
5656
assert config.cids() == [1, 2, 3]
5757

58-
config = ComponentTypeConfig(component_type="battery", inverter=[4, 5])
58+
config = ComponentTypeConfig(meter=[4, 5], inverter=[1, 2, 3])
5959
assert config.cids() == [4, 5]
6060

61-
with pytest.raises(ValueError):
62-
config = ComponentTypeConfig(component_type="grid")
63-
config.cids()
64-
6561

6662
def test_microgrid_config_init(valid_microgrid_config: MicrogridConfig) -> None:
6763
"""Test initialisation of MicrogridConfig with valid configuration data."""
64+
assert valid_microgrid_config.meta is not None
6865
assert valid_microgrid_config.meta.name == "Test Grid"
69-
pv_config = valid_microgrid_config.assets.pv
66+
pv_config = valid_microgrid_config.pv
7067
if pv_config:
7168
_assert_optional_field(
7269
cast(dict[str, float], pv_config["PV1"]).get("peak_power"), 5000
@@ -133,9 +130,10 @@ def test_load_configs(mocker: MockerFixture) -> None:
133130
configs = MicrogridConfig.load_configs(Path("mock_path.toml"))
134131

135132
assert "1" in configs
133+
assert configs["1"].meta is not None
136134
assert configs["1"].meta.name == "Test Grid"
137-
pv_config = configs["1"].assets.pv
138-
battery_config = configs["1"].assets.battery
135+
pv_config = configs["1"].pv
136+
battery_config = configs["1"].battery
139137
if pv_config and battery_config:
140138
_assert_optional_field(
141139
cast(dict[str, float], pv_config["PV1"]).get("peak_power"), 5000

0 commit comments

Comments
 (0)