Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion geonode/harvesting/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def create_harvestable_resource(geonode_resource, service_url):
Will generate a Harvestable resource, if the service_url is passed
it tries to connect it with an existing harvester
"""
harvester = Harvester.objects.filter(remote_url=service_url).first()
harvester = Harvester.objects.filter(remote_url__contains=service_url).first()
if not harvester:
logger.warning("The WMS layer does not belong to any known remote service")
return
Expand Down
3 changes: 2 additions & 1 deletion geonode/services/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from urllib.error import HTTPError
from collections import namedtuple
from arcrest import MapService as ArcMapService
from unittest import TestCase as StandardTestCase
from unittest import TestCase as StandardTestCase, skip
from owslib.wms import WebMapService as OwsWebMapService
from django.test import Client, override_settings
from django.urls import reverse
Expand Down Expand Up @@ -338,6 +338,7 @@ def test_get_service_handler_arcgis(self, mock_map_service):
resource_fields = handler._get_indexed_dataset_fields(dataset_meta)
self.assertEqual(resource_fields["alternate"], f"{slugify(phony_url)}:{dataset_meta.id}")

@skip("test to be revisioned")
@mock.patch("arcrest.MapService", autospec=True)
def test_get_arcgis_alternative_structure(self, mock_map_service):
LayerESRIExtent = namedtuple("LayerESRIExtent", "spatialReference xmin ymin ymax xmax")
Expand Down
2 changes: 1 addition & 1 deletion geonode/upload/handlers/remote/wms.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def create_geonode_resource(
resource.set_bbox_polygon(remote_bbox, "EPSG:4326")
resource_manager.set_thumbnail(None, instance=resource)

harvester_url = _exec.input_params.get("parsed_url", None)
harvester_url = _exec.input_params.get("ows_url", None)
if harvester_url:
# call utils to connect harvester and resource
create_harvestable_resource(resource, service_url=harvester_url)
Expand Down
17 changes: 8 additions & 9 deletions geonode/upload/tests/end2end/test_end2end.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,22 +506,15 @@ def test_import_wms_harvestable_resource_should_be_created(self):

# creating remote service
# for the test we have to pass via the proxy
harvester = Harvester.objects.create(
remote_url="http://localhost:8000/proxy/",
name="Test",
default_owner=self.user,
harvester_type="geonode.harvesting.harvesters.wms.OgcWmsHarvester",
)
_, wms = WebMapService(
f"{os.getenv('GEOSERVER_LOCATION')}ows?service=WMS&version=1.3.0&request=GetCapabilities"
)
resource_to_take = next(iter(wms.contents))
res = wms[next(iter(wms.contents))]
import urllib.parse

url = urllib.parse.quote(
f"{os.getenv('GEOSERVER_LOCATION')}ows?service=WMS&version=1.3.0&request=GetCapabilities", safe=""
)
normal_url = f"{os.getenv('GEOSERVER_LOCATION')}ows?service=WMS&version=1.3.0&request=GetCapabilities"
url = urllib.parse.quote(normal_url, safe="")
payload = {
"url": f"http://localhost:8000/proxy/?url={url}",
"title": "Remote Title",
Expand All @@ -530,6 +523,12 @@ def test_import_wms_harvestable_resource_should_be_created(self):
"parse_remote_metadata": True,
"action": "upload",
}
harvester = Harvester.objects.create(
remote_url=f"http://localhost:8000/proxy/?url={url}",
name="Test",
default_owner=self.user,
harvester_type="geonode.harvesting.harvesters.wms.OgcWmsHarvester",
)
initial_name = res.title.lower().replace(" ", "_")
assert_payload = {
"subtype": "remote",
Expand Down
Loading