diff --git a/powersimdata/scenario/scenario.py b/powersimdata/scenario/scenario.py index 6bb07db1a..3181a1491 100644 --- a/powersimdata/scenario/scenario.py +++ b/powersimdata/scenario/scenario.py @@ -85,8 +85,12 @@ def _set_info(self, descriptor): :param str descriptor: scenario descriptor. """ info = self._scenario_list_manager.get_scenario(descriptor) - if info is not None: - self.info = info + if info is None: + raise ValueError( + f"{descriptor} not found in Scenario List. " + "See available scenarios with Scenario().get_scenario_table()" + ) + self.info = info def _set_status(self): """Sets execution status of scenario.""" diff --git a/powersimdata/scenario/tests/test_scenario.py b/powersimdata/scenario/tests/test_scenario.py new file mode 100644 index 000000000..393b590ee --- /dev/null +++ b/powersimdata/scenario/tests/test_scenario.py @@ -0,0 +1,10 @@ +import pytest + +from powersimdata.scenario.scenario import Scenario + + +@pytest.mark.ssh +def test_bad_scenario_name(): + # This test will fail if we do add a scenario with this name + with pytest.raises(ValueError): + Scenario("this_scenario_does_not_exist")