* adds workflow edit testing for compensations
This commit is contained in:
mpeltriaux 2021-11-12 16:05:26 +01:00
parent 92cfb95789
commit 03ff4098f0
2 changed files with 49 additions and 0 deletions

View File

@ -7,6 +7,7 @@ Created on: 11.11.21
"""
import datetime
from django.contrib.gis.geos import MultiPolygon
from django.urls import reverse
from compensation.models import Compensation
@ -94,6 +95,49 @@ class CompensationWorkflowTestCase(BaseWorkflowTestCase):
self.assertEqual(new_compensation.title, test_title)
self.assert_equal_geometries(new_compensation.geometry.geom, test_geom)
def test_edit(self):
""" Checks that the editing of a compensation works
Returns:
"""
url = reverse("compensation:edit", args=(self.compensation.id,))
self.compensation = self.fill_out_compensation(self.compensation)
new_title = self.create_dummy_string()
new_identifier = self.create_dummy_string()
new_comment = self.create_dummy_string()
new_geometry = MultiPolygon(srid=4326) # Create an empty geometry
check_on_elements = {
self.compensation.title: new_title,
self.compensation.identifier: new_identifier,
self.compensation.comment: new_comment,
}
for k, v in check_on_elements.items():
self.assertNotEqual(k, v)
post_data = {
"identifier": new_identifier,
"title": new_title,
"intervention": self.intervention.id, # just keep the intervention as it is
"comment": new_comment,
"geom": new_geometry.geojson,
}
self.client_user.post(url, post_data)
self.compensation.refresh_from_db()
check_on_elements = {
self.compensation.title: new_title,
self.compensation.identifier: new_identifier,
self.compensation.comment: new_comment,
}
for k, v in check_on_elements.items():
self.assertEqual(k, v)
self.assert_equal_geometries(self.compensation.geometry.geom, new_geometry)
def test_checkability(self):
"""
This tests if the checkability of the compensation (which is defined by the linked intervention's checked

View File

@ -283,6 +283,11 @@ class BaseTestCase(TestCase):
Returns:
"""
# Two empty geometries are basically identical - no further testing
if geom1.empty and geom2.empty:
self.assertTrue(True)
return
if geom1.srid != geom2.srid:
# Due to prior possible transformation of any of these geometries, we need to make sure there exists a
# transformation from one coordinate system into the other, which is valid