diff --git a/Changelog.md b/Changelog.md index 79ca91b..c9334fc 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,7 @@ +Unreleased +------------------------- +* [Enhancement] Add better error handling for missing Provider configuration. + Version 7.9.1 (2024-02-14) ------------------------- * [Bug fix] Don't allow accessing a fullscreen lab directly from a URL, diff --git a/hastexo/provider.py b/hastexo/provider.py index 19b563a..002f2c4 100644 --- a/hastexo/provider.py +++ b/hastexo/provider.py @@ -66,6 +66,9 @@ def init(name): return OpenstackProvider(name, config, sleep_seconds) elif provider_type == "gcloud": return GcloudProvider(name, config, sleep_seconds) + else: + raise ProviderException( + f"No configuration provided for provider {name}") def __init__(self, name, config, sleep): self.name = name diff --git a/tests/unit/test_provider.py b/tests/unit/test_provider.py index 295a02f..14b059a 100644 --- a/tests/unit/test_provider.py +++ b/tests/unit/test_provider.py @@ -169,6 +169,12 @@ def test_init(self): self.assertNotEqual(provider.heat_c, None) self.assertNotEqual(provider.nova_c, None) + def test_init_missing_configuration(self): + self.settings["providers"].pop(self.provider_name) + + with self.assertRaises(ProviderException): + Provider.init(self.provider_name) + def test_generate_ssh_keys(self): provider = Provider.init(self.provider_name)