Skip to content

Commit cc32ec0

Browse files
committed
Update MockMicrogridClient to pass fewer args to _create_mock_api
It was exceeding the pylint limit earlier. Signed-off-by: Sahas Subramanian <[email protected]>
1 parent 3c313b4 commit cc32ec0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

tests/utils/mock_microgrid.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,15 @@ def __init__(self, components: Set[Component], connections: Set[Connection]):
4242
"""
4343
self._component_graph = _MicrogridComponentGraph(components, connections)
4444

45+
self._components = components
46+
4547
bat_channels = self._create_battery_channels()
4648
inv_channels = self._create_inverter_channels()
4749
meter_channels = self._create_meter_channels()
4850
ev_charger_channels = self._create_ev_charger_channels()
4951

5052
mock_api = self._create_mock_api(
51-
components, bat_channels, inv_channels, meter_channels, ev_charger_channels
53+
bat_channels, inv_channels, meter_channels, ev_charger_channels
5254
)
5355
kwargs: Dict[str, Any] = {
5456
"api_client": mock_api,
@@ -199,7 +201,6 @@ def _create_ev_charger_channels(self) -> Dict[int, Broadcast[EVChargerData]]:
199201

200202
def _create_mock_api(
201203
self,
202-
components: Set[Component],
203204
bat_channels: Dict[int, Broadcast[BatteryData]],
204205
inv_channels: Dict[int, Broadcast[InverterData]],
205206
meter_channels: Dict[int, Broadcast[MeterData]],
@@ -218,7 +219,7 @@ def _create_mock_api(
218219
Magic mock instance of MicrogridApiClient.
219220
"""
220221
api = MagicMock()
221-
api.components = AsyncMock(return_value=components)
222+
api.components = AsyncMock(return_value=self._components)
222223
# NOTE that has to be partial, because battery_data has id argument and takes
223224
# channel based on the argument.
224225
api.battery_data = AsyncMock(

0 commit comments

Comments
 (0)