Skip to content

Commit 514db6d

Browse files
committed
Update EVChargerPool.component_data tests to use raw data methods
This eliminates the need for the `start_mock_client` automatic component data streaming tasks, so those are also removed. Signed-off-by: Sahas Subramanian <[email protected]>
1 parent b76d108 commit 514db6d

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

tests/timeseries/test_ev_charger_pool.py

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -107,20 +107,18 @@ async def test_ev_component_data(self, mocker: MockerFixture) -> None:
107107
)
108108
mockgrid.add_ev_chargers(1)
109109

110-
# The component_data method is a bit special because it uses both raw data
111-
# coming from the MicrogridClient to get the component state, and resampler data
112-
# to get the 3-phase current values. So we need both `start_mock_client` and
113-
# `start_mock_datapipeline`.
114-
mockgrid.start_mock_client(lambda client: client.initialize(mocker))
115110
await mockgrid.start_mock_datapipeline(mocker)
116111

117112
evc_id = mockgrid.evc_ids[0]
118113
ev_pool = microgrid.ev_charger_pool()
119114

120115
recv = ev_pool.component_data(evc_id)
121116

117+
await mockgrid.send_ev_charger_data(
118+
[0.0] # only the status gets used from this.
119+
)
120+
await asyncio.sleep(0.05)
122121
await mockgrid.mock_data.send_evc_current([[2, 3, 5]])
123-
await asyncio.sleep(0.1)
124122
status = await recv.receive()
125123
assert (
126124
status.current.value_p1,
@@ -133,8 +131,11 @@ async def test_ev_component_data(self, mocker: MockerFixture) -> None:
133131
)
134132
assert status.state == EVChargerState.MISSING
135133

134+
await mockgrid.send_ev_charger_data(
135+
[0.0] # only the status gets used from this.
136+
)
137+
await asyncio.sleep(0.05)
136138
await mockgrid.mock_data.send_evc_current([[2, 3, None]])
137-
await asyncio.sleep(0.1)
138139
status = await recv.receive()
139140
assert (
140141
status.current.value_p1,
@@ -147,8 +148,11 @@ async def test_ev_component_data(self, mocker: MockerFixture) -> None:
147148
)
148149
assert status.state == EVChargerState.IDLE
149150

151+
await mockgrid.send_ev_charger_data(
152+
[0.0] # only the status gets used from this.
153+
)
154+
await asyncio.sleep(0.05)
150155
await mockgrid.mock_data.send_evc_current([[None, None, None]])
151-
await asyncio.sleep(0.1)
152156
status = await recv.receive()
153157
assert (
154158
status.current.value_p1,
@@ -161,9 +165,12 @@ async def test_ev_component_data(self, mocker: MockerFixture) -> None:
161165
)
162166
assert status.state == EVChargerState.MISSING
163167

164-
await mockgrid.mock_data.send_evc_current([[None, None, None]])
165168
mockgrid.evc_cable_states[evc_id] = EVChargerCableState.EV_PLUGGED
166-
await asyncio.sleep(0.1)
169+
await mockgrid.send_ev_charger_data(
170+
[0.0] # only the status gets used from this.
171+
)
172+
await asyncio.sleep(0.05)
173+
await mockgrid.mock_data.send_evc_current([[None, None, None]])
167174
status = await recv.receive()
168175
assert (
169176
status.current.value_p1,
@@ -176,8 +183,11 @@ async def test_ev_component_data(self, mocker: MockerFixture) -> None:
176183
)
177184
assert status.state == EVChargerState.MISSING
178185

186+
await mockgrid.send_ev_charger_data(
187+
[0.0] # only the status gets used from this.
188+
)
189+
await asyncio.sleep(0.05)
179190
await mockgrid.mock_data.send_evc_current([[4, None, None]])
180-
await asyncio.sleep(0.1)
181191
status = await recv.receive()
182192
assert (
183193
status.current.value_p1,

0 commit comments

Comments
 (0)