Compare commits

..

No commits in common. "2e5345e5220c7d1f889fd19e528fdcc6e72b0b81" and "9c8286a5d1d327949021de06f47826af8925646b" have entirely different histories.

2 changed files with 33 additions and 38 deletions

View File

@ -61,7 +61,7 @@ class AbstractModelAPISerializerV1(AbstractModelAPISerializer):
if konova_code is None:
return None
return {
"id": konova_code.id,
"atom_id": konova_code.atom_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 (id)
json_str (str): The value for the code (atom 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(
id=json_str,
atom_id=json_str,
code_lists__in=[code_list_identifier]
)
except ObjectDoesNotExist as e:
@ -297,12 +297,9 @@ class AbstractCompensationAPISerializerV1Mixin:
"""
deadlines = []
for entry in deadline_data:
try:
deadline_type = entry["type"]
date = entry["date"]
comment = entry["comment"]
except KeyError:
raise ValueError(f"Invalid deadline content. Content was {entry} but should follow the specification")
deadline_type = entry["type"]
date = entry["date"]
comment = entry["comment"]
# Check on validity
if deadline_type not in DeadlineType:
@ -344,14 +341,11 @@ class AbstractCompensationAPISerializerV1Mixin:
"""
states = []
for entry in states_data:
try:
biotope_type = entry["biotope"]
biotope_details = [
self._konova_code_from_json(e, CODELIST_BIOTOPES_EXTRA_CODES_ID) for e in entry["biotope_details"]
]
surface = float(entry["surface"])
except KeyError:
raise ValueError(f"Invalid biotope content. Content was {entry} but should follow the specification ")
biotope_type = entry["biotope"]
biotope_details = [
self._konova_code_from_json(e, CODELIST_BIOTOPES_EXTRA_CODES_ID) for e in entry["biotope_details"]
]
surface = float(entry["surface"])
# Check on validity
if surface <= 0:
@ -360,7 +354,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__id=biotope_type,
biotope_type__atom_id=biotope_type,
surface=surface,
).exclude(
id__in=states
@ -391,19 +385,16 @@ class AbstractCompensationAPISerializerV1Mixin:
"""
actions = []
for entry in actions_data:
try:
action_types = [
self._konova_code_from_json(e, CODELIST_COMPENSATION_ACTION_ID) for e in entry["action_types"]
]
action_details = [
self._konova_code_from_json(e, CODELIST_COMPENSATION_ACTION_DETAIL_ID) for e in entry["action_details"]
]
amount = float(entry["amount"])
# Mapping of old "qm" into "m²"
unit = UnitChoices.m2.value if entry["unit"] == "qm" else entry["unit"]
comment = entry["comment"]
except KeyError:
raise ValueError(f"Invalid action content. Content was {entry} but should follow specification")
action_types = [
self._konova_code_from_json(e, CODELIST_COMPENSATION_ACTION_ID) for e in entry["action_types"]
]
action_details = [
self._konova_code_from_json(e, CODELIST_COMPENSATION_ACTION_DETAIL_ID) for e in entry["action_details"]
]
amount = float(entry["amount"])
# Mapping of old "qm" into "m²"
unit = UnitChoices.m2.value if entry["unit"] == "qm" else entry["unit"]
comment = entry["comment"]
# Check on validity
if amount <= 0:

View File

@ -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.schneider.fetcher import ParcelFetcher
from konova.utils.wfs.spatial import ParcelWFSFetcher
class GeometryTestCase(BaseTestCase):
@ -63,14 +63,18 @@ class GeometryTestCase(BaseTestCase):
num_conflict = GeometryConflict.objects.all().count()
self.assertEqual(0, num_conflict)
def test_fetch(self):
""" Tests the fetching functionality of ParcelFetcher
def test_wfs_fetch(self):
""" Tests the fetching functionality of ParcelWFSFetcher
+++ Test relies on the availability of the spatial computation component 'Schneider' +++
+++ Test relies on the availability of the RLP Flurstück WFS +++
Returns:
"""
fetcher = ParcelFetcher(geometry=self.geom_1)
features = fetcher.get_parcels()
self.assertNotEqual(0, len(features), msg="Spatial fetcher get feature did not work!")
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!")