Skip to content

Commit

Permalink
Raise error on provider not found
Browse files Browse the repository at this point in the history
  • Loading branch information
nuwang committed Apr 13, 2024
1 parent b38e6f0 commit 9cf27ee
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
5 changes: 1 addition & 4 deletions cloudbridge/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,7 @@ def discover_providers(self):
"""
for _, modname, _ in pkgutil.iter_modules(providers.__path__):
log.debug("Importing provider: %s", modname)
try:
self._import_provider(modname)
except Exception as e:
log.debug("Could not import provider: %s", e)
self._import_provider(modname)

def _import_provider(self, module_name):
"""
Expand Down
3 changes: 2 additions & 1 deletion tests/test_cloud_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ def test_get_provider_class_invalid(self):
self.assertIsNone(CloudProviderFactory().get_provider_class("aws1"))

def test_find_provider_include_mocks(self):
providers = CloudProviderFactory().get_all_provider_classes()
self.assertTrue(
any(cls for cls
in CloudProviderFactory().get_all_provider_classes()
in providers
if issubclass(cls, TestMockHelperMixin)),
"expected to find at least one mock provider")

Expand Down

0 comments on commit 9cf27ee

Please sign in to comment.