1818
1919import frequenz .sdk .microgrid ._graph as gr
2020from frequenz .sdk .microgrid .client import Connection , MicrogridGrpcClient
21- from frequenz .sdk .microgrid .component import Component , ComponentCategory , InverterType
21+ from frequenz .sdk .microgrid .component import (
22+ Component ,
23+ ComponentCategory ,
24+ GridMetadata ,
25+ InverterType ,
26+ )
2227
2328from .mock_api import MockGrpcServer , MockMicrogridServicer
2429
@@ -816,8 +821,16 @@ async def test_refresh_from_api(self) -> None:
816821 servicer .set_connections ([(101 , 111 ), (111 , 131 )])
817822 await graph .refresh_from_api (client )
818823
824+ # Note: we need to add GriMetadata as a dict here, because that's what
825+ # the ComponentGraph does too, and we need to be able to compare the
826+ # two graphs.
819827 expected = {
820- Component (101 , ComponentCategory .GRID ),
828+ Component (
829+ 101 ,
830+ ComponentCategory .GRID ,
831+ None ,
832+ asdict (GridMetadata (max_current = 0.0 )), # type: ignore
833+ ),
821834 Component (111 , ComponentCategory .METER ),
822835 Component (131 , ComponentCategory .EV_CHARGER ),
823836 }
@@ -843,7 +856,12 @@ async def test_refresh_from_api(self) -> None:
843856 servicer .set_connections ([(707 , 717 ), (717 , 727 ), (727 , 737 ), (717 , 747 )])
844857 await graph .refresh_from_api (client )
845858 expected = {
846- Component (707 , ComponentCategory .GRID ),
859+ Component (
860+ 707 ,
861+ ComponentCategory .GRID ,
862+ None ,
863+ asdict (GridMetadata (max_current = 0.0 )), # type: ignore
864+ ),
847865 Component (717 , ComponentCategory .METER ),
848866 Component (727 , ComponentCategory .INVERTER , InverterType .NONE ),
849867 Component (737 , ComponentCategory .BATTERY ),
@@ -1146,7 +1164,7 @@ def test__validate_grid_endpoint(self) -> None:
11461164 gr .InvalidGraphError ,
11471165 match = r"Grid endpoint 1 has graph predecessors: \[Component"
11481166 r"\(component_id=99, category=<ComponentCategory.METER: 2>, "
1149- r"type=None\)\]" ,
1167+ r"type=None, metadata=None \)\]" ,
11501168 ) as _err_predecessors :
11511169 graph ._validate_grid_endpoint ()
11521170
0 commit comments