diff --git a/README.md b/README.md index ec3f3846..7be51e6a 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,7 @@ IMPORTER_HANDLERS = os.getenv('IMPORTER_HANDLERS', [ 'importer.handlers.kml.handler.KMLFileHandler', 'importer.handlers.csv.handler.CSVFileHandler', 'importer.handlers.geotiff.handler.GeoTiffFileHandler', - 'importer.handlers.metadata.xml.handler.XMLFileHandler + 'importer.handlers.xml.handler.XMLFileHandler ]) ``` diff --git a/importer/handlers/common/metadata.py b/importer/handlers/common/metadata.py index 5af84344..67492a8a 100644 --- a/importer/handlers/common/metadata.py +++ b/importer/handlers/common/metadata.py @@ -1,7 +1,7 @@ import logging from geonode.resource.enumerator import ExecutionRequestAction as exa from importer.handlers.base import BaseHandler -from importer.handlers.metadata.serializer import MetadataFileSerializer +from importer.handlers.xml.serializer import MetadataFileSerializer from importer.utils import ImporterRequestAction as ira logger = logging.getLogger(__name__) diff --git a/importer/handlers/xml/handler.py b/importer/handlers/xml/handler.py index 0a17c0e6..213397f1 100644 --- a/importer/handlers/xml/handler.py +++ b/importer/handlers/xml/handler.py @@ -5,7 +5,7 @@ from geonode.resource.enumerator import ExecutionRequestAction as exa from geonode.resource.manager import resource_manager from importer.handlers.common.metadata import MetadataFileHandler -from importer.handlers.metadata.xml.exceptions import InvalidXmlException +from importer.handlers.xml.exceptions import InvalidXmlException from importer.orchestrator import orchestrator from owslib.etree import etree as dlxml @@ -34,7 +34,7 @@ def can_handle(_data) -> bool: ) @staticmethod - def is_valid(files, user): + def is_valid(files, user=None): """ Define basic validation steps """ diff --git a/importer/handlers/xml/tests.py b/importer/handlers/xml/tests.py index 8bb8c4bf..67c167c6 100644 --- a/importer/handlers/xml/tests.py +++ b/importer/handlers/xml/tests.py @@ -5,8 +5,8 @@ from importer import project_dir from importer.models import ResourceHandlerInfo from importer.orchestrator import orchestrator -from importer.handlers.metadata.xml.exceptions import InvalidXmlException -from importer.handlers.metadata.xml.handler import XMLFileHandler +from importer.handlers.xml.exceptions import InvalidXmlException +from importer.handlers.xml.handler import XMLFileHandler class TestXMLFileHandler(TestCase): diff --git a/importer/tests/unit/test_task.py b/importer/tests/unit/test_task.py index f51a02a2..897d6d94 100644 --- a/importer/tests/unit/test_task.py +++ b/importer/tests/unit/test_task.py @@ -1,5 +1,6 @@ import os import os +import shutil from django.conf import settings from django.contrib.auth import get_user_model @@ -470,9 +471,14 @@ def test_rollback_works_as_expected_raster( if exec_id: ExecutionRequest.objects.filter(exec_id=str(exec_id)).delete() + @override_settings(MEDIA_ROOT="/tmp/") def test_import_metadata_should_work_as_expected(self): - handler = "importer.handlers.metadata.xml.handler.XMLFileHandler" + handler = "importer.handlers.xml.handler.XMLFileHandler" + # lets copy the file to the temporary folder + # later will be removed valid_xml = f"{settings.PROJECT_ROOT}/base/fixtures/test_xml.xml" + shutil.copy(valid_xml, '/tmp') + user, _ = get_user_model().objects.get_or_create(username="admin") valid_files = {"base_file": valid_xml, 'xml_file': valid_xml}