Skip to content

Commit 30c25ae

Browse files
fix: fix tests
Signed-off-by: Matthias Wende <[email protected]>
1 parent f80505d commit 30c25ae

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

tests/test_config.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
"""Tests for the frequenz.lib.notebooks.config module."""
55

6+
from pathlib import Path
67
from typing import Any, cast
78

89
import pytest
@@ -122,12 +123,14 @@ def test_load_configs(mocker: MockerFixture) -> None:
122123
1.ctype.battery.component = [301, 302, 303, 304, 305, 306]
123124
1.pv.PV1.peak_power = 5000
124125
1.pv.PV1.rated_power = 4500
125-
1.pv.PV2peak_power = 8000
126-
1.pv.PV2rated_power = 7000
126+
1.pv.PV2.peak_power = 8000
127+
1.pv.PV2.rated_power = 7000
127128
1.battery.BAT1.capacity = 10000
128129
"""
129-
mocker.patch("builtins.open", mocker.mock_open(read_data=toml_data.encode("utf-8")))
130-
configs = MicrogridConfig.load_configs("mock_path.toml")
130+
mock_file = mocker.mock_open(read_data=toml_data.encode("utf-8"))
131+
mocker.patch("pathlib.Path.open", mock_file)
132+
mocker.patch("pathlib.Path.is_file", mocker.Mock(return_value=True))
133+
configs = MicrogridConfig.load_configs(Path("mock_path.toml"))
131134

132135
assert "1" in configs
133136
assert configs["1"].meta.name == "Test Grid"

0 commit comments

Comments
 (0)