diff --git a/tests/network/test_topology.py b/tests/network/test_topology.py index 62e04ee4c..04a98e2d1 100644 --- a/tests/network/test_topology.py +++ b/tests/network/test_topology.py @@ -957,6 +957,17 @@ def setup_class(self): def test_to_geopandas(self): # further tests of to_geopandas are conducted in test_geopandas_helper.py + # set up edisgo object with georeferenced LV + edisgo_geo = EDisGo( + ding0_grid=pytest.ding0_test_network_3_path, legacy_ding0_grids=False + ) + test_suits = { + "mv": {"edisgo_obj": self.edisgo, "mode": "mv", "lv_grid_id": None}, + "lv": {"edisgo_obj": edisgo_geo, "mode": "lv", "lv_grid_id": 1164120002}, + "mv+lv": {"edisgo_obj": edisgo_geo, "mode": None, "lv_grid_id": None}, + } + # further tests of to_geopandas are conducted in test_geopandas_helper.py + # set up edisgo object with georeferenced LV edisgo_geo = EDisGo( ding0_grid=pytest.ding0_test_network_3_path, legacy_ding0_grids=False @@ -976,6 +987,20 @@ def test_to_geopandas(self): "transformers_gdf", ] + for test_suit, params in test_suits.items(): + # call to_geopandas() function with different settings + geopandas_container = params["edisgo_obj"].topology.to_geopandas( + mode=params["mode"], lv_grid_id=params["lv_grid_id"] + ) + + assert isinstance(geopandas_container, GeoPandasGridContainer) + + # check that content of geodataframes is the same as content of original + # dataframes + for attr_str in attrs: + grid = getattr(geopandas_container, "grid") + attr = getattr(geopandas_container, attr_str) + grid_attr = getattr(grid, attr_str.replace("_gdf", "_df")) for test_suit, params in test_suits.items(): # call to_geopandas() function with different settings geopandas_container = params["edisgo_obj"].topology.to_geopandas( @@ -991,8 +1016,10 @@ def test_to_geopandas(self): attr = getattr(geopandas_container, attr_str) grid_attr = getattr(grid, attr_str.replace("_gdf", "_df")) + assert isinstance(attr, GeoDataFrame) assert isinstance(attr, GeoDataFrame) + common_cols = list(set(attr.columns).intersection(grid_attr.columns)) common_cols = list(set(attr.columns).intersection(grid_attr.columns)) assert_frame_equal( @@ -1000,6 +1027,11 @@ def test_to_geopandas(self): grid_attr[common_cols].sort_index(), check_names=False, ) + assert_frame_equal( + attr[common_cols].sort_index(), + grid_attr[common_cols].sort_index(), + check_names=False, + ) def test_from_csv(self): """ @@ -1775,6 +1807,7 @@ def test_connect_to_lv(self): ) # check new heat pump assert self.edisgo.topology.loads_df.at[comp_name, "p_set"] == 0.1 + assert self.edisgo.topology.loads_df.at[comp_name, "p_set"] == 0.1 # ############# storage unit ################# # test existing substation ID (voltage level 7)