Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
mattiagiupponi committed Mar 7, 2024
1 parent 0dc9d2e commit d3b1c01
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
])

```
Expand Down
2 changes: 1 addition & 1 deletion importer/handlers/common/metadata.py
Original file line number Diff line number Diff line change
@@ -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__)
Expand Down
4 changes: 2 additions & 2 deletions importer/handlers/xml/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
"""
Expand Down
4 changes: 2 additions & 2 deletions importer/handlers/xml/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
8 changes: 7 additions & 1 deletion importer/tests/unit/test_task.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import os
import shutil

from django.conf import settings
from django.contrib.auth import get_user_model
Expand Down Expand Up @@ -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}

Expand Down

0 comments on commit d3b1c01

Please sign in to comment.