Merge pull request '284_285_API_changes' (#296) from 284_285_API_changes into master
Reviewed-on: SGD-Nord/konova#296
This commit is contained in:
commit
35745d6ee6
@ -61,7 +61,7 @@ class AbstractModelAPISerializerV1(AbstractModelAPISerializer):
|
|||||||
if konova_code is None:
|
if konova_code is None:
|
||||||
return None
|
return None
|
||||||
return {
|
return {
|
||||||
"atom_id": konova_code.atom_id,
|
"id": konova_code.id,
|
||||||
"long_name": konova_code.long_name,
|
"long_name": konova_code.long_name,
|
||||||
"short_name": konova_code.short_name,
|
"short_name": konova_code.short_name,
|
||||||
}
|
}
|
||||||
@ -70,7 +70,7 @@ class AbstractModelAPISerializerV1(AbstractModelAPISerializer):
|
|||||||
""" Returns a konova code instance
|
""" Returns a konova code instance
|
||||||
|
|
||||||
Args:
|
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
|
code_list_identifier (str): From which konova code list this code is supposed to be from
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
@ -83,7 +83,7 @@ class AbstractModelAPISerializerV1(AbstractModelAPISerializer):
|
|||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
code = KonovaCode.objects.get(
|
code = KonovaCode.objects.get(
|
||||||
atom_id=json_str,
|
id=json_str,
|
||||||
code_lists__in=[code_list_identifier]
|
code_lists__in=[code_list_identifier]
|
||||||
)
|
)
|
||||||
except ObjectDoesNotExist as e:
|
except ObjectDoesNotExist as e:
|
||||||
@ -297,9 +297,12 @@ class AbstractCompensationAPISerializerV1Mixin:
|
|||||||
"""
|
"""
|
||||||
deadlines = []
|
deadlines = []
|
||||||
for entry in deadline_data:
|
for entry in deadline_data:
|
||||||
|
try:
|
||||||
deadline_type = entry["type"]
|
deadline_type = entry["type"]
|
||||||
date = entry["date"]
|
date = entry["date"]
|
||||||
comment = entry["comment"]
|
comment = entry["comment"]
|
||||||
|
except KeyError:
|
||||||
|
raise ValueError(f"Invalid deadline content. Content was {entry} but should follow the specification")
|
||||||
|
|
||||||
# Check on validity
|
# Check on validity
|
||||||
if deadline_type not in DeadlineType:
|
if deadline_type not in DeadlineType:
|
||||||
@ -341,11 +344,14 @@ class AbstractCompensationAPISerializerV1Mixin:
|
|||||||
"""
|
"""
|
||||||
states = []
|
states = []
|
||||||
for entry in states_data:
|
for entry in states_data:
|
||||||
|
try:
|
||||||
biotope_type = entry["biotope"]
|
biotope_type = entry["biotope"]
|
||||||
biotope_details = [
|
biotope_details = [
|
||||||
self._konova_code_from_json(e, CODELIST_BIOTOPES_EXTRA_CODES_ID) for e in entry["biotope_details"]
|
self._konova_code_from_json(e, CODELIST_BIOTOPES_EXTRA_CODES_ID) for e in entry["biotope_details"]
|
||||||
]
|
]
|
||||||
surface = float(entry["surface"])
|
surface = float(entry["surface"])
|
||||||
|
except KeyError:
|
||||||
|
raise ValueError(f"Invalid biotope content. Content was {entry} but should follow the specification ")
|
||||||
|
|
||||||
# Check on validity
|
# Check on validity
|
||||||
if surface <= 0:
|
if surface <= 0:
|
||||||
@ -354,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
|
# 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
|
# entries, we will use to set the new actions
|
||||||
state = states_manager.filter(
|
state = states_manager.filter(
|
||||||
biotope_type__atom_id=biotope_type,
|
biotope_type__id=biotope_type,
|
||||||
surface=surface,
|
surface=surface,
|
||||||
).exclude(
|
).exclude(
|
||||||
id__in=states
|
id__in=states
|
||||||
@ -385,6 +391,7 @@ class AbstractCompensationAPISerializerV1Mixin:
|
|||||||
"""
|
"""
|
||||||
actions = []
|
actions = []
|
||||||
for entry in actions_data:
|
for entry in actions_data:
|
||||||
|
try:
|
||||||
action_types = [
|
action_types = [
|
||||||
self._konova_code_from_json(e, CODELIST_COMPENSATION_ACTION_ID) for e in entry["action_types"]
|
self._konova_code_from_json(e, CODELIST_COMPENSATION_ACTION_ID) for e in entry["action_types"]
|
||||||
]
|
]
|
||||||
@ -395,6 +402,8 @@ class AbstractCompensationAPISerializerV1Mixin:
|
|||||||
# Mapping of old "qm" into "m²"
|
# Mapping of old "qm" into "m²"
|
||||||
unit = UnitChoices.m2.value if entry["unit"] == "qm" else entry["unit"]
|
unit = UnitChoices.m2.value if entry["unit"] == "qm" else entry["unit"]
|
||||||
comment = entry["comment"]
|
comment = entry["comment"]
|
||||||
|
except KeyError:
|
||||||
|
raise ValueError(f"Invalid action content. Content was {entry} but should follow specification")
|
||||||
|
|
||||||
# Check on validity
|
# Check on validity
|
||||||
if amount <= 0:
|
if amount <= 0:
|
||||||
|
@ -9,7 +9,7 @@ from django.contrib.gis.db.models.functions import Translate
|
|||||||
|
|
||||||
from konova.models import Geometry, GeometryConflict
|
from konova.models import Geometry, GeometryConflict
|
||||||
from konova.tests.test_views import BaseTestCase
|
from konova.tests.test_views import BaseTestCase
|
||||||
from konova.utils.wfs.spatial import ParcelWFSFetcher
|
from konova.utils.schneider.fetcher import ParcelFetcher
|
||||||
|
|
||||||
|
|
||||||
class GeometryTestCase(BaseTestCase):
|
class GeometryTestCase(BaseTestCase):
|
||||||
@ -63,18 +63,14 @@ class GeometryTestCase(BaseTestCase):
|
|||||||
num_conflict = GeometryConflict.objects.all().count()
|
num_conflict = GeometryConflict.objects.all().count()
|
||||||
self.assertEqual(0, num_conflict)
|
self.assertEqual(0, num_conflict)
|
||||||
|
|
||||||
def test_wfs_fetch(self):
|
def test_fetch(self):
|
||||||
""" Tests the fetching functionality of ParcelWFSFetcher
|
""" 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:
|
Returns:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
fetcher = ParcelWFSFetcher(
|
fetcher = ParcelFetcher(geometry=self.geom_1)
|
||||||
geometry_id=self.geom_1.id,
|
features = fetcher.get_parcels()
|
||||||
)
|
self.assertNotEqual(0, len(features), msg="Spatial fetcher get feature did not work!")
|
||||||
features = fetcher.get_features(
|
|
||||||
"ave:Flurstueck",
|
|
||||||
)
|
|
||||||
self.assertNotEqual(0, len(features), msg="Spatial wfs get feature did not work!")
|
|
||||||
|
Loading…
Reference in New Issue
Block a user