Skip to content

Commit 0056292

Browse files
committed
Fix last_id in fake service when setting dispatches
Signed-off-by: Mathias L. Baumann <[email protected]>
1 parent 9850141 commit 0056292

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

RELEASE_NOTES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
## Bug Fixes
44

55
* Fix missing dependency in last release
6+
* The `FakeClient.set_dispatches()` method now correctly updates `FakeService._last_id` which is used to generate unique dispatch IDs.
7+

src/frequenz/client/dispatch/test/client.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@ def set_dispatches(self, microgrid_id: int, value: list[Dispatch]) -> None:
5454
"""
5555
self._service.dispatches[microgrid_id] = value
5656

57+
if len(value) == 0:
58+
return
59+
60+
# Max between last id and the max id in the list
61+
# pylint: disable=protected-access
62+
self._service._last_id = max(
63+
self._service._last_id, max(dispatch.id for dispatch in value)
64+
)
65+
# pylint: enable=protected-access
66+
5767
@property
5868
def _service(self) -> FakeService:
5969
"""The fake service.

0 commit comments

Comments
 (0)