Skip to content

Commit

Permalink
[Fixes #12124] GNIP 100: Assets - tests
Browse files Browse the repository at this point in the history
  • Loading branch information
etj committed May 9, 2024
1 parent 291f93e commit 64b4dee
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 3 additions & 3 deletions geonode/assets/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ def get_handler(self, asset):
asset_cls = asset if isinstance(asset, type) else asset.__class__
ret = self._registry.get(asset_cls, None)
if not ret:
logger.warning(f"Could not find handler for asset {asset_cls}::{asset.__class__}")
logger.warning("available asset types:")
logger.warning(f"Could not find asset handler for {asset_cls}::{asset.__class__}")
logger.warning("Available asset types:")
for k, v in self._registry.items():
logger.warning(f"{k} --> {v}")
logger.warning(f"{k} --> {v.__class__.__name__}")
return ret


Expand Down
10 changes: 8 additions & 2 deletions geonode/assets/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,17 @@

class AssetsTests(APITestCase):

def test_default_handler(self):
def test_handler_registry(self):
# Test registry
self.assertIsNotNone(asset_handler_registry)
# Test default handler
asset_handler = asset_handler_registry.get_default_handler()
self.assertIsNotNone(asset_handler)
# in the default config, the default handler is the Local one
self.assertIsInstance(asset_handler, LocalAssetHandler, "Bad default Asset handler found")
# Test None
self.assertIsNone(asset_handler_registry.get_handler(None))
# Test class without handler
self.assertIsNone(asset_handler_registry.get_handler(AssetsTests))

def test_creation_and_delete_data_cloned(self):
u, _ = get_user_model().objects.get_or_create(username="admin")
Expand Down

0 comments on commit 64b4dee

Please sign in to comment.