From 64b4dee65eea9c6d68f4c6cac10f070ff3b1a7eb Mon Sep 17 00:00:00 2001 From: etj Date: Thu, 9 May 2024 12:35:20 +0200 Subject: [PATCH] [Fixes #12124] GNIP 100: Assets - tests --- geonode/assets/handlers.py | 6 +++--- geonode/assets/tests.py | 10 ++++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/geonode/assets/handlers.py b/geonode/assets/handlers.py index 09e902ee183..ad2190b46ce 100644 --- a/geonode/assets/handlers.py +++ b/geonode/assets/handlers.py @@ -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 diff --git a/geonode/assets/tests.py b/geonode/assets/tests.py index 2abfe6d615a..5d94f24dcd3 100644 --- a/geonode/assets/tests.py +++ b/geonode/assets/tests.py @@ -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")