|
|
|
@ -37,6 +37,63 @@ class CompensationWorkflowTestCase(BaseWorkflowTestCase):
|
|
|
|
|
# Create a fresh dummy (non-valid) compensation before each test
|
|
|
|
|
self.compensation = self.create_dummy_compensation()
|
|
|
|
|
|
|
|
|
|
def test_new(self):
|
|
|
|
|
""" Test the creation of a compensation
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
# Prepare url and form data to be posted
|
|
|
|
|
new_url = reverse("compensation:new")
|
|
|
|
|
test_id = self.create_dummy_string()
|
|
|
|
|
test_title = self.create_dummy_string()
|
|
|
|
|
test_geom = self.create_dummy_geometry()
|
|
|
|
|
post_data = {
|
|
|
|
|
"identifier": test_id,
|
|
|
|
|
"title": test_title,
|
|
|
|
|
"geom": test_geom.geojson,
|
|
|
|
|
"intervention": self.intervention.id,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Preserve the current number of intervention's compensations
|
|
|
|
|
num_compensations = self.intervention.compensations.count()
|
|
|
|
|
self.client_user.post(new_url, post_data)
|
|
|
|
|
|
|
|
|
|
self.intervention.refresh_from_db()
|
|
|
|
|
self.assertEqual(num_compensations + 1, self.intervention.compensations.count())
|
|
|
|
|
new_compensation = self.intervention.compensations.get(identifier=test_id)
|
|
|
|
|
self.assertEqual(new_compensation.identifier, test_id)
|
|
|
|
|
self.assertEqual(new_compensation.title, test_title)
|
|
|
|
|
self.assert_equal_geometries(new_compensation.geometry.geom, test_geom)
|
|
|
|
|
|
|
|
|
|
def test_new_from_intervention(self):
|
|
|
|
|
""" Test the creation of a compensation from a given intervention
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
# Prepare url and form data to be posted
|
|
|
|
|
new_url = reverse("compensation:new", args=(self.intervention.id,))
|
|
|
|
|
test_id = self.create_dummy_string()
|
|
|
|
|
test_title = self.create_dummy_string()
|
|
|
|
|
test_geom = self.create_dummy_geometry()
|
|
|
|
|
post_data = {
|
|
|
|
|
"identifier": test_id,
|
|
|
|
|
"title": test_title,
|
|
|
|
|
"geom": test_geom.geojson,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Preserve the current number of intervention's compensations
|
|
|
|
|
num_compensations = self.intervention.compensations.count()
|
|
|
|
|
self.client_user.post(new_url, post_data)
|
|
|
|
|
|
|
|
|
|
self.intervention.refresh_from_db()
|
|
|
|
|
self.assertEqual(num_compensations + 1, self.intervention.compensations.count())
|
|
|
|
|
new_compensation = self.intervention.compensations.get(identifier=test_id)
|
|
|
|
|
self.assertEqual(new_compensation.identifier, test_id)
|
|
|
|
|
self.assertEqual(new_compensation.title, test_title)
|
|
|
|
|
self.assert_equal_geometries(new_compensation.geometry.geom, test_geom)
|
|
|
|
|
|
|
|
|
|
def test_checkability(self):
|
|
|
|
|
"""
|
|
|
|
|
This tests if the checkability of the compensation (which is defined by the linked intervention's checked
|
|
|
|
|