File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed
src/frequenz/client/dispatch/test Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -123,12 +123,15 @@ async def UpdateMicrogridDispatch(
123123 request : DispatchUpdateRequest ,
124124 ) -> Empty :
125125 """Update a dispatch."""
126- dispatch = next ((d for d in self .dispatches if d .id == request .id ), None )
126+ index = next (
127+ (i for i , d in enumerate (self .dispatches ) if d .id == request .id ),
128+ None ,
129+ )
127130
128- if dispatch is None :
131+ if index is None :
129132 return Empty ()
130133
131- pb_dispatch = dispatch .to_protobuf ()
134+ pb_dispatch = self . dispatches [ index ] .to_protobuf ()
132135
133136 # Go through the paths in the update mask and update the dispatch
134137 for path in request .update_mask .paths :
@@ -174,6 +177,8 @@ async def UpdateMicrogridDispatch(
174177 dispatch = Dispatch .from_protobuf (pb_dispatch )
175178 dispatch .update_time = datetime .now (tz = timezone .utc )
176179
180+ self .dispatches [index ] = dispatch
181+
177182 return Empty ()
178183
179184 async def GetMicrogridDispatch (
Original file line number Diff line number Diff line change @@ -81,6 +81,7 @@ async def test_update_dispatch() -> None:
8181 assert dispatch == sample
8282
8383 await client .update (dispatch .id , {"recurrence.interval" : 4 })
84+ assert client .dispatches [0 ].recurrence .interval == 4
8485
8586
8687async def test_get_dispatch () -> None :
You can’t perform that action at this time.
0 commit comments