From d830b7f88bacc65b70da3c9af53461f1cbe1fa69 Mon Sep 17 00:00:00 2001 From: mpeltriaux Date: Wed, 11 Dec 2024 11:04:37 +0100 Subject: [PATCH] # Testfixes * fixes test cases --- compensation/tests/compensation/test_workflow.py | 6 +++--- compensation/tests/ecoaccount/test_workflow.py | 4 ++-- ema/tests/test_workflow.py | 4 ++-- ema/tests/unit/test_forms.py | 4 ++-- intervention/tests/test_workflow.py | 2 +- intervention/tests/unit/test_forms.py | 4 ++-- konova/forms/geometry_form.py | 4 ++-- konova/tests/test_geometries.py | 1 + konova/tests/test_views.py | 1 + templates/map/client/config.json | 2 +- 10 files changed, 17 insertions(+), 15 deletions(-) diff --git a/compensation/tests/compensation/test_workflow.py b/compensation/tests/compensation/test_workflow.py index 3f024483..7b6c89a0 100644 --- a/compensation/tests/compensation/test_workflow.py +++ b/compensation/tests/compensation/test_workflow.py @@ -54,7 +54,7 @@ class CompensationWorkflowTestCase(BaseWorkflowTestCase): post_data = { "identifier": test_id, "title": test_title, - "geom": geom_json, + "output": geom_json, "intervention": self.intervention.id, } pre_creation_intervention_log_count = self.intervention.log.count() @@ -94,7 +94,7 @@ class CompensationWorkflowTestCase(BaseWorkflowTestCase): post_data = { "identifier": test_id, "title": test_title, - "geom": geom_json, + "output": geom_json, } pre_creation_intervention_log_count = self.intervention.log.count() @@ -150,7 +150,7 @@ class CompensationWorkflowTestCase(BaseWorkflowTestCase): "title": new_title, "intervention": self.intervention.id, # just keep the intervention as it is "comment": new_comment, - "geom": geojson, + "output": geojson, } self.client_user.post(url, post_data) self.compensation.refresh_from_db() diff --git a/compensation/tests/ecoaccount/test_workflow.py b/compensation/tests/ecoaccount/test_workflow.py index 85f7db54..6fe8184f 100644 --- a/compensation/tests/ecoaccount/test_workflow.py +++ b/compensation/tests/ecoaccount/test_workflow.py @@ -46,7 +46,7 @@ class EcoAccountWorkflowTestCase(BaseWorkflowTestCase): post_data = { "identifier": test_id, "title": test_title, - "geom": geom_json, + "output": geom_json, "surface": test_deductable_surface, "conservation_office": test_conservation_office.id } @@ -103,7 +103,7 @@ class EcoAccountWorkflowTestCase(BaseWorkflowTestCase): "identifier": new_identifier, "title": new_title, "comment": new_comment, - "geom": new_geometry.geojson, + "output": new_geometry.geojson, "surface": test_deductable_surface, "conservation_office": test_conservation_office.id } diff --git a/ema/tests/test_workflow.py b/ema/tests/test_workflow.py index c6228112..c4bcbde1 100644 --- a/ema/tests/test_workflow.py +++ b/ema/tests/test_workflow.py @@ -46,7 +46,7 @@ class EmaWorkflowTestCase(BaseWorkflowTestCase): post_data = { "identifier": test_id, "title": test_title, - "geom": geom_json, + "output": geom_json, "conservation_office": test_conservation_office.id } self.client_user.post(new_url, post_data) @@ -99,7 +99,7 @@ class EmaWorkflowTestCase(BaseWorkflowTestCase): "identifier": new_identifier, "title": new_title, "comment": new_comment, - "geom": new_geometry.geojson, + "output": new_geometry.geojson, "conservation_office": test_conservation_office.id } self.client_user.post(url, post_data) diff --git a/ema/tests/unit/test_forms.py b/ema/tests/unit/test_forms.py index d66fd14b..40865bb8 100644 --- a/ema/tests/unit/test_forms.py +++ b/ema/tests/unit/test_forms.py @@ -48,7 +48,7 @@ class NewEmaFormTestCase(BaseTestCase): ) geom_form_data = json.loads(geom_form_data) geom_form_data = { - "geom": json.dumps(geom_form_data) + "output": json.dumps(geom_form_data) } geom_form = SimpleGeomForm(geom_form_data) @@ -116,7 +116,7 @@ class EditEmaFormTestCase(BaseTestCase): ) geom_form_data = json.loads(geom_form_data) geom_form_data = { - "geom": json.dumps(geom_form_data) + "output": json.dumps(geom_form_data) } geom_form = SimpleGeomForm(geom_form_data) diff --git a/intervention/tests/test_workflow.py b/intervention/tests/test_workflow.py index 4bd61d92..962aead2 100644 --- a/intervention/tests/test_workflow.py +++ b/intervention/tests/test_workflow.py @@ -60,7 +60,7 @@ class InterventionWorkflowTestCase(BaseWorkflowTestCase): post_data = { "identifier": test_id, "title": test_title, - "geom": geom_json, + "output": geom_json, } response = self.client_user.post( new_url, diff --git a/intervention/tests/unit/test_forms.py b/intervention/tests/unit/test_forms.py index 1c4306c2..c4e04813 100644 --- a/intervention/tests/unit/test_forms.py +++ b/intervention/tests/unit/test_forms.py @@ -62,7 +62,7 @@ class NewInterventionFormTestCase(BaseTestCase): ) geom_form_data = json.loads(geom_form_data) geom_form_data = { - "geom": json.dumps(geom_form_data) + "output": json.dumps(geom_form_data) } geom_form = SimpleGeomForm(geom_form_data) @@ -104,7 +104,7 @@ class EditInterventionFormTestCase(NewInterventionFormTestCase): ) geom_form_data = json.loads(geom_form_data) geom_form_data = { - "geom": json.dumps(geom_form_data) + "output": json.dumps(geom_form_data) } geom_form = SimpleGeomForm(geom_form_data) diff --git a/konova/forms/geometry_form.py b/konova/forms/geometry_form.py index 3f885fae..6d62b737 100644 --- a/konova/forms/geometry_form.py +++ b/konova/forms/geometry_form.py @@ -62,7 +62,7 @@ class SimpleGeomForm(BaseForm): is_valid = True # Get geojson from form - geom = self.data["output"] + geom = self.data.get("output", None) if geom is None or len(geom) == 0: # empty geometry is a valid geometry self.cleaned_data["output"] = MultiPolygon(srid=DEFAULT_SRID_RLP).ewkt @@ -71,7 +71,7 @@ class SimpleGeomForm(BaseForm): # Write submitted data back into form field to make sure invalid geometry # will be rendered again on failed submit - self.initialize_form_field("output", self.data["output"]) + self.initialize_form_field("output", self.data.get("output", None)) # Read geojson into gdal geometry # HINT: This can be simplified if the geojson format holds data in epsg:4326 (GDAL provides direct creation for diff --git a/konova/tests/test_geometries.py b/konova/tests/test_geometries.py index 047e285d..a8b2c36f 100644 --- a/konova/tests/test_geometries.py +++ b/konova/tests/test_geometries.py @@ -124,6 +124,7 @@ class GeometryTestCase(BaseTestCase): { "type": "Feature", "geometry": json.loads(p.json), + "properties": {}, } for p in polygons ] diff --git a/konova/tests/test_views.py b/konova/tests/test_views.py index 95fb8367..9857384b 100644 --- a/konova/tests/test_views.py +++ b/konova/tests/test_views.py @@ -345,6 +345,7 @@ class BaseTestCase(TestCase): { "type": "Feature", "geometry": json.loads(geometry.geojson), + "properties": {}, } ] } diff --git a/templates/map/client/config.json b/templates/map/client/config.json index 26c0d16b..4703eb7d 100644 --- a/templates/map/client/config.json +++ b/templates/map/client/config.json @@ -32,7 +32,7 @@ { "projection": "EPSG:25832", "center_lonlat": [ 7.0, 50.0 ], - "zoom": 12, + "zoom": 9.2, "min_zoom": 5, "max_zoom": 24, "scalebar": true,