#49 Calculation implementation
* implements update routine for Geometry model * reorganizes fields of Parcel and District * adds tests * simplifies usage of ParcelWFSFetcher
This commit is contained in:
@@ -8,7 +8,6 @@ Created on: 15.12.21
|
||||
from django.contrib.gis.db.models.functions import Translate
|
||||
|
||||
from konova.models import Geometry, GeometryConflict
|
||||
from konova.settings import PARCEL_WFS_USER, PARCEL_WFS_PW
|
||||
from konova.tests.test_views import BaseTestCase
|
||||
from konova.utils.wfs.spatial import ParcelWFSFetcher
|
||||
|
||||
@@ -25,6 +24,22 @@ class GeometryTestCase(BaseTestCase):
|
||||
geom=geom,
|
||||
)
|
||||
|
||||
def test_geometry_parcel_caluclation(self):
|
||||
""" Tests whether newly created geometries already have parcels calculated during save
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
has_parcels = self.geom_1.parcels.all().exists()
|
||||
self.assertFalse(has_parcels, msg=f"{self.geom_1.id} has parcels but should not!")
|
||||
self.geom_1.update_parcels()
|
||||
self.geom_1.refresh_from_db()
|
||||
parcels = self.geom_1.parcels.all()
|
||||
has_parcels = parcels.exists()
|
||||
parcel_districts = parcels.values_list("district", flat=True)
|
||||
self.assertTrue(has_parcels, msg=f"{self.geom_1.id} has no parcels but should!")
|
||||
self.assertEqual(parcels.count(), len(parcel_districts), msg=f"Not every parcel has exactly one district!")
|
||||
|
||||
def test_geometry_conflict(self):
|
||||
""" Tests whether a geometry conflict will be present in case of identical/overlaying geometries and
|
||||
if the conflict will be resolved if one geometry is edited.
|
||||
@@ -50,17 +65,13 @@ class GeometryTestCase(BaseTestCase):
|
||||
def test_wfs_fetch(self):
|
||||
""" Tests the fetching functionality of ParcelWFSFetcher
|
||||
|
||||
+++ Test relies on the availability of the RLP Gemarkung WFS +++
|
||||
+++ Test relies on the availability of the RLP Flurstück WFS +++
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
fetcher = ParcelWFSFetcher(
|
||||
base_url="https://www.geoportal.rlp.de/registry/wfs/519",
|
||||
version="2.0.0",
|
||||
geometry=self.geom_1,
|
||||
auth_user=PARCEL_WFS_USER,
|
||||
auth_pw=PARCEL_WFS_PW
|
||||
geometry_id=self.geom_1.id,
|
||||
)
|
||||
features = fetcher.get_features(
|
||||
"ave:Flurstueck",
|
||||
|
||||
Reference in New Issue
Block a user