@@ -38,6 +38,9 @@ class APIV1GetTestCase(BaseAPIV1TestCase):
|
||||
content = json.loads(response.content)
|
||||
geojson = content[str(obj.id)]
|
||||
self.assertEqual(response.status_code, 200, msg=response.content)
|
||||
return geojson
|
||||
|
||||
def _assert_geojson_format(self, geojson):
|
||||
try:
|
||||
geojson["type"]
|
||||
geojson["coordinates"]
|
||||
@@ -49,7 +52,6 @@ class APIV1GetTestCase(BaseAPIV1TestCase):
|
||||
props["modified_on"]
|
||||
except KeyError as e:
|
||||
self.fail(e)
|
||||
return geojson
|
||||
|
||||
def test_get_intervention(self):
|
||||
""" Tests api GET
|
||||
@@ -60,6 +62,7 @@ class APIV1GetTestCase(BaseAPIV1TestCase):
|
||||
self.intervention.share_with(self.superuser)
|
||||
url = reverse("api:v1:intervention", args=(str(self.intervention.id),))
|
||||
geojson = self._test_get_object(self.intervention, url)
|
||||
self._assert_geojson_format(geojson)
|
||||
try:
|
||||
props = geojson["properties"]
|
||||
props["responsible"]
|
||||
@@ -89,6 +92,7 @@ class APIV1GetTestCase(BaseAPIV1TestCase):
|
||||
|
||||
url = reverse("api:v1:compensation", args=(str(self.compensation.id),))
|
||||
geojson = self._test_get_object(self.compensation, url)
|
||||
self._assert_geojson_format(geojson)
|
||||
try:
|
||||
props = geojson["properties"]
|
||||
props["is_cef"]
|
||||
@@ -114,6 +118,7 @@ class APIV1GetTestCase(BaseAPIV1TestCase):
|
||||
|
||||
url = reverse("api:v1:ecoaccount", args=(str(self.eco_account.id),))
|
||||
geojson = self._test_get_object(self.eco_account, url)
|
||||
self._assert_geojson_format(geojson)
|
||||
try:
|
||||
props = geojson["properties"]
|
||||
props["deductable_surface"]
|
||||
@@ -142,6 +147,7 @@ class APIV1GetTestCase(BaseAPIV1TestCase):
|
||||
|
||||
url = reverse("api:v1:ema", args=(str(self.ema.id),))
|
||||
geojson = self._test_get_object(self.ema, url)
|
||||
self._assert_geojson_format(geojson)
|
||||
try:
|
||||
props = geojson["properties"]
|
||||
props["responsible"]
|
||||
@@ -155,3 +161,27 @@ class APIV1GetTestCase(BaseAPIV1TestCase):
|
||||
except KeyError as e:
|
||||
self.fail(e)
|
||||
|
||||
def test_get_deduction(self):
|
||||
""" Tests api GET
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
self.deduction.intervention.share_with(self.superuser)
|
||||
|
||||
url = reverse("api:v1:deduction", args=(str(self.deduction.id),))
|
||||
_json = self._test_get_object(self.deduction, url)
|
||||
try:
|
||||
_json["id"]
|
||||
_json["eco_account"]
|
||||
_json["eco_account"]["id"]
|
||||
_json["eco_account"]["identifier"]
|
||||
_json["eco_account"]["title"]
|
||||
_json["surface"]
|
||||
_json["intervention"]
|
||||
_json["intervention"]["id"]
|
||||
_json["intervention"]["identifier"]
|
||||
_json["intervention"]["title"]
|
||||
except KeyError as e:
|
||||
self.fail(e)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user