From 882468cde621270b55361fecf260de14634cdac5 Mon Sep 17 00:00:00 2001 From: mpeltriaux Date: Wed, 1 Feb 2023 08:08:52 +0100 Subject: [PATCH] #285 Drop atom_id from API * refactors code usage from atom_id to id inside of api app --- api/utils/serializer/v1/serializer.py | 8 ++++---- konova/tests/test_geometries.py | 18 +++++++----------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/api/utils/serializer/v1/serializer.py b/api/utils/serializer/v1/serializer.py index c01746c3..8779f4ef 100644 --- a/api/utils/serializer/v1/serializer.py +++ b/api/utils/serializer/v1/serializer.py @@ -61,7 +61,7 @@ class AbstractModelAPISerializerV1(AbstractModelAPISerializer): if konova_code is None: return None return { - "atom_id": konova_code.atom_id, + "id": konova_code.id, "long_name": konova_code.long_name, "short_name": konova_code.short_name, } @@ -70,7 +70,7 @@ class AbstractModelAPISerializerV1(AbstractModelAPISerializer): """ Returns a konova code instance Args: - json_str (str): The value for the code (atom id) + json_str (str): The value for the code (id) code_list_identifier (str): From which konova code list this code is supposed to be from Returns: @@ -83,7 +83,7 @@ class AbstractModelAPISerializerV1(AbstractModelAPISerializer): return None try: code = KonovaCode.objects.get( - atom_id=json_str, + id=json_str, code_lists__in=[code_list_identifier] ) except ObjectDoesNotExist as e: @@ -360,7 +360,7 @@ class AbstractCompensationAPISerializerV1Mixin: # If this exact data is already existing, we do not create it new. Instead put it's id in the list of # entries, we will use to set the new actions state = states_manager.filter( - biotope_type__atom_id=biotope_type, + biotope_type__id=biotope_type, surface=surface, ).exclude( id__in=states diff --git a/konova/tests/test_geometries.py b/konova/tests/test_geometries.py index e73070d8..cf518853 100644 --- a/konova/tests/test_geometries.py +++ b/konova/tests/test_geometries.py @@ -9,7 +9,7 @@ from django.contrib.gis.db.models.functions import Translate from konova.models import Geometry, GeometryConflict from konova.tests.test_views import BaseTestCase -from konova.utils.wfs.spatial import ParcelWFSFetcher +from konova.utils.schneider.fetcher import ParcelFetcher class GeometryTestCase(BaseTestCase): @@ -63,18 +63,14 @@ class GeometryTestCase(BaseTestCase): num_conflict = GeometryConflict.objects.all().count() self.assertEqual(0, num_conflict) - def test_wfs_fetch(self): - """ Tests the fetching functionality of ParcelWFSFetcher + def test_fetch(self): + """ Tests the fetching functionality of ParcelFetcher - +++ Test relies on the availability of the RLP Flurstück WFS +++ + +++ Test relies on the availability of the spatial computation component 'Schneider' +++ Returns: """ - fetcher = ParcelWFSFetcher( - geometry_id=self.geom_1.id, - ) - features = fetcher.get_features( - "ave:Flurstueck", - ) - self.assertNotEqual(0, len(features), msg="Spatial wfs get feature did not work!") + fetcher = ParcelFetcher(geometry=self.geom_1) + features = fetcher.get_parcels() + self.assertNotEqual(0, len(features), msg="Spatial fetcher get feature did not work!")