Skip to content

Commit

Permalink
[Fixes #11494] Implement relations between resources - test fixings
Browse files Browse the repository at this point in the history
  • Loading branch information
etj committed Oct 10, 2023
1 parent 8e42bfc commit ff5e5ef
Showing 1 changed file with 28 additions and 25 deletions.
53 changes: 28 additions & 25 deletions geonode/base/api/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2662,16 +2662,19 @@ def assert_linkedres_contains(self, payload, element: str, expected_elements: It
self.fail(f"Elements {dikt} could not be found in output: {payload}")

def test_linked_resource_for_maps_mixed(self):
_d = []
try:
# data preparation
_d = LinkedResource.objects.create(source_id=self.doc.id, target_id=self.map.id)
_m = MapLayer(
map=self.map,
dataset=self.dataset,
name=self.dataset.name,
current_style="test_style",
ows_url="https://maps.geosolutionsgroup.com/geoserver/wms",
).save()
_d.append(LinkedResource.objects.create(source_id=self.doc.id, target_id=self.map.id))
_d.append(
MapLayer(
map=self.map,
dataset=self.dataset,
name=self.dataset.name,
current_style="test_style",
ows_url="https://maps.geosolutionsgroup.com/geoserver/wms",
).save()
)

# call the API
url = reverse("base-resources-linked_resources", args=[self.map.id])
Expand All @@ -2698,10 +2701,8 @@ def test_linked_resource_for_maps_mixed(self):
self.assert_linkedres_contains(payload, "linked_by", ({"pk": self.doc.id, "title": self.doc.title},))

finally:
if _d:
_d.delete()
if _m:
_m.delete()
for d in _d:
d.delete()

def test_linked_resources_for_maps(self):
try:
Expand Down Expand Up @@ -2737,6 +2738,7 @@ def test_linked_resources_for_maps(self):
_m.delete()

def test_linked_resource_for_dataset(self):
_m = None
try:
# data preparation
_m = MapLayer(
Expand Down Expand Up @@ -2768,16 +2770,19 @@ def test_linked_resource_for_dataset(self):
_m.delete()

def test_linked_resource_for_datasets_mixed(self):
_d = []
try:
# data preparation
_d = LinkedResource.objects.create(source_id=self.doc.id, target_id=self.dataset.id)
_m = MapLayer(
map=self.map,
dataset=self.dataset,
name=self.dataset.name,
current_style="test_style",
ows_url="https://maps.geosolutionsgroup.com/geoserver/wms",
).save()
_d.append(LinkedResource.objects.create(source_id=self.doc.id, target_id=self.dataset.id))
_d.append(
MapLayer(
map=self.map,
dataset=self.dataset,
name=self.dataset.name,
current_style="test_style",
ows_url="https://maps.geosolutionsgroup.com/geoserver/wms",
).save()
)

# call the API
url = reverse("base-resources-linked_resources", args=[self.dataset.id])
Expand Down Expand Up @@ -2807,15 +2812,13 @@ def test_linked_resource_for_datasets_mixed(self):
)

finally:
if _d:
_d.delete()
if _m:
_m.delete()
for d in _d:
d.delete()

def test_linked_resource_deprecated_pagination(self):
_d = []
try:
# data preparation
_d = []
_d.append(LinkedResource.objects.create(source_id=self.doc.id, target_id=self.dataset.id))
_d.append(LinkedResource.objects.create(source_id=self.doc.id, target_id=self.map.id))

Expand Down

0 comments on commit ff5e5ef

Please sign in to comment.