@@ -115,7 +115,10 @@ def test_grid_with_automatic_tap_regulator(self, grid_with_tap_regulator: Grid):
115115 assert output ["transformer_tap_regulator" ]["tap_pos" ][0 ] > 0
116116
117117
118- ExtendedComponentType = StrEnum ("ExtendedComponentType" , {x .name : x .value for x in ComponentType } | {"onzin" : "onzin" })
118+ ExtendedComponentType = StrEnum ( # type: ignore
119+ "ExtendedComponentType" ,
120+ {component .name : component .value for component in ComponentType } | {"DUMMY_EXTRA_COMPONENT" : "dummy" },
121+ )
119122
120123
121124class TestPowerGridModelInterfaceMethods :
@@ -126,10 +129,13 @@ def test_update_grid(self):
126129 grid .node = ExtendedNodeArray (grid .node .data )
127130 grid .line = ExtendedLineArray (grid .line .data )
128131
132+ # Patch ComponentType to include a value that is not present in the grid as an attribute
129133 with patch ("power_grid_model_ds._core.power_grid_model_interface.ComponentType" , ExtendedComponentType ):
130134 core_interface = PowerGridModelInterface (grid = grid )
131135 core_interface .create_input_from_grid ()
132136 core_interface .calculate_power_flow ()
137+ # Mock additional component type that is not in the grid
138+ core_interface .output_data ["dummy" ] = np .array ([])
133139 core_interface .update_grid ()
134140
135141 grid = core_interface .grid
@@ -139,24 +145,6 @@ def test_update_grid(self):
139145 # all lines have a current
140146 assert all (grid .line .i_from > 0 )
141147
142- # def test_update_grid_missing_component(self, core_interface_after_loadflow: PowerGridModelInterface):
143- # """Test that update grid works when a component is missing in the grid."""
144- # del core_interface_after_loadflow.grid.source
145-
146- # core_interface_after_loadflow.update_grid()
147-
148- # # voltage should be in neighbourhood of 10500
149- # grid = core_interface_after_loadflow.grid
150- # assert not all(grid.node.is_empty("u"))
151- # assert not hasattr(grid, "source")
152-
153- def test_input_from_grid_missing_component (self , grid : Grid ):
154- # Mimic no source in grid
155- del grid .source
156-
157- core_interface = PowerGridModelInterface (grid = grid )
158- assert "source" not in core_interface .create_input_from_grid ()
159-
160148 def test_update_model (self ):
161149 """Test whether a pgm model can be updated and returns different results"""
162150 grid_generator = RadialGridGenerator (grid_class = Grid , nr_nodes = 5 , nr_sources = 1 , nr_nops = 0 )
0 commit comments