From b704d2ca30335245cf256dc9554ca6b74bc6b95e Mon Sep 17 00:00:00 2001 From: joda9 Date: Wed, 10 Jul 2024 19:17:02 +0200 Subject: [PATCH] Add test for missing annual demand --- tests/network/test_timeseries.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/network/test_timeseries.py b/tests/network/test_timeseries.py index 2c05eda4..b06fc945 100644 --- a/tests/network/test_timeseries.py +++ b/tests/network/test_timeseries.py @@ -1793,6 +1793,26 @@ def test_predefined_conventional_loads_by_sector(self, caplog): ).values, ).all() + # test Error if 'annual_consumption' is missing + # Save the original 'annual_consumption' values + original_annual_consumption = self.edisgo.topology.loads_df[ + "annual_consumption" + ].copy() + # Set 'annual_consumption' to None for the test + self.edisgo.topology.loads_df["annual_consumption"] = None + with pytest.raises(AttributeError) as exc_info: + self.edisgo.timeseries.predefined_conventional_loads_by_sector( + self.edisgo, "demandlib" + ) + assert ( + exc_info.value.args[0] + == "The annual consumption of some loads is missing. Please provide" + ) + # Restore the original 'annual_consumption' values + self.edisgo.topology.loads_df[ + "annual_consumption" + ] = original_annual_consumption + def test_predefined_charging_points_by_use_case(self, caplog): index = pd.date_range("1/1/2018", periods=3, freq="H") self.edisgo.timeseries.timeindex = index