Skip to content

Commit d198f49

Browse files
committed
Update EVChargerPool's component_data test to run slower
This is the only test that still depends on a lower level mock, and it needs it because it combines power and state values. If it is flaky, we'll have to add multi stage testing - with a fast test first, and a slower one if that fails, etc. Signed-off-by: Sahas Subramanian <[email protected]>
1 parent 52db8e5 commit d198f49

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

tests/timeseries/test_ev_charger_pool.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,11 @@ async def test_ev_power( # pylint: disable=too-many-locals
9999

100100
async def test_ev_component_data(self, mocker: MockerFixture) -> None:
101101
"""Test the component_data method of EVChargerPool."""
102-
mockgrid = MockMicrogrid(grid_side_meter=False, api_client_streaming=True)
102+
mockgrid = MockMicrogrid(
103+
grid_side_meter=False,
104+
api_client_streaming=True,
105+
sample_rate_s=0.05,
106+
)
103107
mockgrid.add_ev_chargers(1)
104108

105109
# The component_data method is a bit special because it uses both raw data
@@ -115,7 +119,7 @@ async def test_ev_component_data(self, mocker: MockerFixture) -> None:
115119
recv = ev_pool.component_data(evc_id)
116120

117121
await mockgrid.mock_data.send_evc_current([[2, 3, 5]])
118-
await asyncio.sleep(0.02)
122+
await asyncio.sleep(0.1)
119123
status = await recv.receive()
120124
assert (
121125
status.current.value_p1,
@@ -125,7 +129,7 @@ async def test_ev_component_data(self, mocker: MockerFixture) -> None:
125129
assert status.state == EVChargerState.MISSING
126130

127131
await mockgrid.mock_data.send_evc_current([[2, 3, None]])
128-
await asyncio.sleep(0.02)
132+
await asyncio.sleep(0.1)
129133
status = await recv.receive()
130134
assert (
131135
status.current.value_p1,
@@ -135,7 +139,7 @@ async def test_ev_component_data(self, mocker: MockerFixture) -> None:
135139
assert status.state == EVChargerState.IDLE
136140

137141
await mockgrid.mock_data.send_evc_current([[None, None, None]])
138-
await asyncio.sleep(0.02)
142+
await asyncio.sleep(0.1)
139143
status = await recv.receive()
140144
assert (
141145
status.current.value_p1,
@@ -146,7 +150,7 @@ async def test_ev_component_data(self, mocker: MockerFixture) -> None:
146150

147151
await mockgrid.mock_data.send_evc_current([[None, None, None]])
148152
mockgrid.evc_cable_states[evc_id] = EVChargerCableState.EV_PLUGGED
149-
await asyncio.sleep(0.02)
153+
await asyncio.sleep(0.1)
150154
status = await recv.receive()
151155
assert (
152156
status.current.value_p1,
@@ -156,7 +160,7 @@ async def test_ev_component_data(self, mocker: MockerFixture) -> None:
156160
assert status.state == EVChargerState.MISSING
157161

158162
await mockgrid.mock_data.send_evc_current([[4, None, None]])
159-
await asyncio.sleep(0.02)
163+
await asyncio.sleep(0.1)
160164
status = await recv.receive()
161165
assert (
162166
status.current.value_p1,
@@ -166,3 +170,4 @@ async def test_ev_component_data(self, mocker: MockerFixture) -> None:
166170
assert status.state == EVChargerState.EV_PLUGGED
167171

168172
await mockgrid.cleanup()
173+
await ev_pool.stop()

0 commit comments

Comments
 (0)