1717 ComponentCategory ,
1818 Connection ,
1919 Location ,
20- Metadata ,
20+ MicrogridInfo ,
2121)
2222
2323from frequenz .sdk .microgrid import connection_manager
2424
25+ _MICROGRID_ID = MicrogridId (1 )
26+
2527
2628class TestMicrogridApi :
2729 """Test for MicropgridApi."""
@@ -91,17 +93,25 @@ def connections(self) -> list[list[Connection]]:
9193 return connections
9294
9395 @pytest .fixture
94- def metadata (self ) -> Metadata :
95- """Fetch the microgrid metadata .
96+ def microgrid (self ) -> MicrogridInfo :
97+ """Fetch the microgrid information .
9698
9799 Returns:
98- the microgrid metadata.
100+ the information about the microgrid
99101 """
100- return Metadata (
101- microgrid_id = MicrogridId (8 ),
102+ return MicrogridInfo (
103+ id = _MICROGRID_ID ,
104+ enterprise_id = EnterpriseId (1 ),
105+ name = "test" ,
106+ delivery_area = DeliveryArea (
107+ code = "test" , code_type = EnergyMarketCodeType .EUROPE_EIC
108+ ),
109+ status = MicrogridStatus .ACTIVE ,
110+ create_timestamp = datetime .now (tz = timezone .utc ),
102111 location = Location (
103112 latitude = 52.520008 ,
104113 longitude = 13.404954 ,
114+ country_code = "DE" ,
105115 ),
106116 )
107117
@@ -111,15 +121,15 @@ async def test_connection_manager(
111121 _insecure_channel_mock : MagicMock ,
112122 components : list [list [Component ]],
113123 connections : list [list [Connection ]],
114- metadata : Metadata ,
124+ microgrid : MicrogridInfo ,
115125 ) -> None :
116126 """Test microgrid api.
117127
118128 Args:
119129 _insecure_channel_mock: insecure channel mock from `mock.patch`
120130 components: components
121131 connections: connections
122- metadata : the metadata of the microgrid
132+ microgrid : the information about the microgrid
123133 """
124134 microgrid_client = MagicMock ()
125135 microgrid_client .list_components = AsyncMock (side_effect = components )
@@ -167,8 +177,8 @@ async def test_connection_manager(
167177 assert set (graph .components ()) == set (components [0 ])
168178 assert set (graph .connections ()) == set (connections [0 ])
169179
170- assert api .microgrid_id == metadata . microgrid_id
171- assert api .location == metadata .location
180+ assert api .microgrid_id == microgrid . id
181+ assert api .location == microgrid .location
172182
173183 # It should not be possible to initialize method once again
174184 with pytest .raises (AssertionError ):
@@ -181,24 +191,24 @@ async def test_connection_manager(
181191 assert set (graph .components ()) == set (components [0 ])
182192 assert set (graph .connections ()) == set (connections [0 ])
183193
184- assert api .microgrid_id == metadata . microgrid_id
185- assert api .location == metadata .location
194+ assert api .microgrid_id == microgrid . id
195+ assert api .location == microgrid .location
186196
187197 @mock .patch ("grpc.aio.insecure_channel" )
188198 async def test_connection_manager_another_method (
189199 self ,
190200 _insecure_channel_mock : MagicMock ,
191201 components : list [list [Component ]],
192202 connections : list [list [Connection ]],
193- metadata : Metadata ,
203+ microgrid : MicrogridInfo ,
194204 ) -> None :
195205 """Test if the api was not deallocated.
196206
197207 Args:
198208 _insecure_channel_mock: insecure channel mock
199209 components: components
200210 connections: connections
201- metadata : the metadata of the microgrid
211+ microgrid : the information about the microgrid
202212 """
203213 microgrid_client = MagicMock ()
204214 microgrid_client .components = AsyncMock (return_value = [])
@@ -210,5 +220,5 @@ async def test_connection_manager_another_method(
210220 assert set (graph .components ()) == set (components [0 ])
211221 assert set (graph .connections ()) == set (connections [0 ])
212222
213- assert api .microgrid_id == metadata . microgrid_id
214- assert api .location == metadata .location
223+ assert api .microgrid_id == microgrid . id
224+ assert api .location == microgrid .location
0 commit comments