diff --git a/geonode/upload/handlers/remote/tests/test_wms.py b/geonode/upload/handlers/remote/tests/test_wms.py index 5435e849710..b21a243484b 100644 --- a/geonode/upload/handlers/remote/tests/test_wms.py +++ b/geonode/upload/handlers/remote/tests/test_wms.py @@ -17,6 +17,7 @@ # ######################################################################### from collections import namedtuple +from urllib.parse import ParseResult from django.test import TestCase from mock import MagicMock, patch from geonode.upload.api.exceptions import ImportException @@ -133,7 +134,7 @@ def test_prepare_import_should_not_update_the_execid(self, remote_wms): prepare_import should update the execid if the parse_remote_metadata is False """ - fake_url = MagicMock(shema="http", netloc="fake", path="foo", query="bar") + fake_url = ParseResult(scheme="http", netloc="fake", path="/foo", params="", query="bar", fragment="") remote_wms.get_cleaned_url_params.return_value = fake_url, None, None, None try: @@ -165,7 +166,7 @@ def test_prepare_import_should_update_the_execid(self, get_wms_resource, remote_ if the parse_remote_metadata is True """ # remote_wms = MagicMock(title="updated_title", bbox=[1,2,3,4]) - fake_url = MagicMock(shema="http", netloc="fake", path="foo", query="bar") + fake_url = ParseResult(scheme="http", netloc="fake", path="/foo", params="", query="bar", fragment="") remote_wms.get_cleaned_url_params.return_value = fake_url, None, None, None obj = namedtuple("WmsObj", field_names=["title", "boundingBoxWGS84"]) diff --git a/geonode/upload/handlers/remote/wms.py b/geonode/upload/handlers/remote/wms.py index 69bb444992a..8d4722084dc 100644 --- a/geonode/upload/handlers/remote/wms.py +++ b/geonode/upload/handlers/remote/wms.py @@ -76,8 +76,10 @@ def prepare_import(self, files, execution_id, **kwargs): """ _exec = orchestrator.get_execution_object(exec_id=execution_id) cleaned_url, _, _, _ = WmsServiceHandler.get_cleaned_url_params(_exec.input_params.get("url")) + parsed_url = f"{cleaned_url.scheme}://{cleaned_url.netloc}{cleaned_url.path}" - ows_url = f"{parsed_url}?{cleaned_url.query}" + ows_url = cleaned_url._replace(params="", fragment="").geturl() + to_update = { "ows_url": ows_url, "parsed_url": parsed_url,