@@ -64,6 +64,7 @@ class TestComponentGraph:
6464
6565 @pytest .fixture ()
6666 def sample_input_components (self ) -> Set [Component ]:
67+ """Create a sample set of components for testing purposes."""
6768 return {
6869 Component (11 , ComponentCategory .GRID ),
6970 Component (21 , ComponentCategory .METER ),
@@ -74,6 +75,7 @@ def sample_input_components(self) -> Set[Component]:
7475
7576 @pytest .fixture ()
7677 def sample_input_connections (self ) -> Set [Connection ]:
78+ """Create a sample set of connections for testing purposes."""
7779 return {
7880 Connection (11 , 21 ),
7981 Connection (21 , 41 ),
@@ -95,6 +97,7 @@ def sample_graph(
9597 return _graph_implementation
9698
9799 def test_without_filters (self ) -> None :
100+ """Test the graph component query without filters."""
98101 _graph_implementation = gr ._MicrogridComponentGraph ()
99102 graph : gr .ComponentGraph = _graph_implementation
100103
@@ -210,6 +213,7 @@ def test_without_filters(self) -> None:
210213 def test_filter_graph_components_by_id (
211214 self , sample_graph : gr .ComponentGraph , ids : Set [int ], expected : Set [Component ]
212215 ) -> None :
216+ """Test the graph component query with component ID filter."""
213217 # with component_id filter specified, we get back only components whose ID
214218 # matches one of the specified values
215219 assert len (sample_graph .components (component_id = ids )) == len (expected )
@@ -260,6 +264,7 @@ def test_filter_graph_components_by_type(
260264 types : Set [ComponentCategory ],
261265 expected : Set [Component ],
262266 ) -> None :
267+ """Test the graph component query with component category filter."""
263268 # with component_id filter specified, we get back only components whose ID
264269 # matches one of the specified values
265270 assert len (sample_graph .components (component_category = types )) == len (expected )
@@ -292,6 +297,7 @@ def test_filter_graph_components_with_composite_filter(
292297 types : Set [ComponentCategory ],
293298 expected : Set [Component ],
294299 ) -> None :
300+ """Test the graph component query with composite filter."""
295301 # when both filters are applied, they are combined via AND logic, i.e.
296302 # the component must have one of the specified IDs and be of one of
297303 # the specified types
@@ -306,11 +312,13 @@ def test_filter_graph_components_with_composite_filter(
306312 def test_components_without_filters (
307313 self , sample_input_components : Set [Component ], sample_graph : gr .ComponentGraph
308314 ) -> None :
315+ """Test the graph component query without filters."""
309316 # without any filter applied, we get back all the components in the graph
310317 assert len (sample_graph .components ()) == len (sample_input_components )
311318 assert sample_graph .components () == sample_input_components
312319
313320 def test_connection_filters (self ) -> None :
321+ """Test the graph connection query with filters."""
314322 _graph_implementation = gr ._MicrogridComponentGraph (
315323 components = {
316324 Component (1 , ComponentCategory .GRID ),
@@ -528,6 +536,7 @@ class Test_MicrogridComponentGraph:
528536 """
529537
530538 def test___init__ (self ) -> None :
539+ """Test the constructor."""
531540 # it is possible to instantiate an empty graph, but
532541 # it will not be considered valid until it has been
533542 # populated with components and connections
@@ -604,6 +613,7 @@ def test___init__(self) -> None:
604613 )
605614
606615 def test_refresh_from (self ) -> None :
616+ """Test the refresh_from method."""
607617 graph = gr ._MicrogridComponentGraph ()
608618 assert set (graph .components ()) == set ()
609619 assert list (graph .connections ()) == []
@@ -765,6 +775,7 @@ def pretend_to_correct_errors(_g: gr._MicrogridComponentGraph) -> None:
765775 graph .validate ()
766776
767777 async def test_refresh_from_api (self ) -> None :
778+ """Test the refresh_from_api method."""
768779 graph = gr ._MicrogridComponentGraph ()
769780 assert graph .components () == set ()
770781 assert graph .connections () == set ()
@@ -885,6 +896,7 @@ async def test_refresh_from_api(self) -> None:
885896 assert await server .graceful_shutdown ()
886897
887898 def test_validate (self ) -> None :
899+ """Test the validate method."""
888900 # `validate` will fail if any of the following are the case:
889901 #
890902 # * the graph data is not valid
@@ -953,6 +965,7 @@ def test_validate(self) -> None:
953965 graph .validate ()
954966
955967 def test__validate_graph (self ) -> None :
968+ """Test the _validate_graph method."""
956969 # to ensure clean testing of the individual method,
957970 # we cheat by setting underlying graph data directly
958971
@@ -1003,6 +1016,7 @@ def test__validate_graph(self) -> None:
10031016 graph ._validate_graph ()
10041017
10051018 def test__validate_graph_root (self ) -> None :
1019+ """Test the _validate_graph_root method."""
10061020 # to ensure clean testing of the individual method,
10071021 # we cheat by setting underlying graph data directly
10081022
@@ -1125,6 +1139,7 @@ def test__validate_graph_root(self) -> None:
11251139 graph ._validate_graph_root ()
11261140
11271141 def test__validate_grid_endpoint (self ) -> None :
1142+ """Test the _validate_grid_endpoint method."""
11281143 # to ensure clean testing of the individual method,
11291144 # we cheat by setting underlying graph data directly
11301145
@@ -1194,6 +1209,7 @@ def test__validate_grid_endpoint(self) -> None:
11941209 graph ._validate_grid_endpoint ()
11951210
11961211 def test__validate_intermediary_components (self ) -> None :
1212+ """Test the _validate_intermediary_components method."""
11971213 # to ensure clean testing of the individual method,
11981214 # we cheat by setting underlying graph data directly
11991215
@@ -1247,6 +1263,7 @@ def test__validate_intermediary_components(self) -> None:
12471263 graph ._validate_intermediary_components ()
12481264
12491265 def test__validate_leaf_components (self ) -> None :
1266+ """Test the _validate_leaf_components method."""
12501267 # to ensure clean testing of the individual method,
12511268 # we cheat by setting underlying graph data directly
12521269
@@ -1336,6 +1353,7 @@ def test__validate_leaf_components(self) -> None:
13361353 graph ._validate_leaf_components ()
13371354
13381355 def test_graph_correction (self ) -> None :
1356+ """Test the graph correction functionality."""
13391357 # Simple test cases for our built-in graph correction
13401358 # functionality. We test only with `refresh_from`:
13411359 # for `refresh_from_api` it suffices to test that any
0 commit comments