parent
ea14a01f89
commit
037d3a8fee
@ -7,6 +7,7 @@ Created on: 11.11.21
|
|||||||
"""
|
"""
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
from django.contrib.gis.geos import MultiPolygon
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
|
||||||
from compensation.models import Compensation
|
from compensation.models import Compensation
|
||||||
@ -94,6 +95,49 @@ class CompensationWorkflowTestCase(BaseWorkflowTestCase):
|
|||||||
self.assertEqual(new_compensation.title, test_title)
|
self.assertEqual(new_compensation.title, test_title)
|
||||||
self.assert_equal_geometries(new_compensation.geometry.geom, test_geom)
|
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):
|
def test_checkability(self):
|
||||||
"""
|
"""
|
||||||
This tests if the checkability of the compensation (which is defined by the linked intervention's checked
|
This tests if the checkability of the compensation (which is defined by the linked intervention's checked
|
||||||
|
@ -283,6 +283,11 @@ class BaseTestCase(TestCase):
|
|||||||
Returns:
|
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:
|
if geom1.srid != geom2.srid:
|
||||||
# Due to prior possible transformation of any of these geometries, we need to make sure there exists a
|
# 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
|
# transformation from one coordinate system into the other, which is valid
|
||||||
|
Loading…
Reference in New Issue
Block a user