Skip to content

Commit 2162eaf

Browse files
committed
Update MockMicrogrid to drop half the data for some inverters
For inverters with component_id > 100, in particular. This can be used to test some scenarios including when an inverter goes down, the soc calculation gets done without the corresponding battery. Signed-off-by: Sahas Subramanian <[email protected]>
1 parent ffa7589 commit 2162eaf

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tests/timeseries/mock_microgrid.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,13 @@ def battery_msg(value: float) -> ComponentData:
145145
f"Component id {request.id} unsupported by MockMicrogrid"
146146
)
147147
for value in range(1, 10):
148-
yield next_msg(value=value + request.id)
148+
# for inverters with component_id > 100, send only half the messages.
149+
if request.id % 10 == cls.inverter_id_suffix:
150+
if request.id < 100 or value <= 5:
151+
yield next_msg(value=value + request.id)
152+
else:
153+
yield next_msg(value=value + request.id)
154+
149155
time.sleep(0.1)
150156

151157
mocker.patch.object(servicer, "GetComponentData", get_component_data)

0 commit comments

Comments
 (0)