Skip to content

Commit

Permalink
👌 rename 'canHaveGeometry' to 'allowGeometry'
Browse files Browse the repository at this point in the history
  • Loading branch information
annashamray committed Dec 3, 2021
1 parent 51555d1 commit 28789a8
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 27 deletions.
4 changes: 2 additions & 2 deletions src/objects/api/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ components:
nullable: true
description: Point, linestring or polygon object which represents the coordinates
of the object. Geometry can be added only if the related OBJECTTYPE allows
this (`OBJECTTYPE.canHaveGeometry = true` or `OBJECTTYPE.canHaveGeometry`
this (`OBJECTTYPE.allowGeometry = true` or `OBJECTTYPE.allowGeometry`
doesn't exist)
startAt:
type: string
Expand Down Expand Up @@ -796,7 +796,7 @@ components:
nullable: true
description: Point, linestring or polygon object which represents the coordinates
of the object. Geometry can be added only if the related OBJECTTYPE allows
this (`OBJECTTYPE.canHaveGeometry = true` or `OBJECTTYPE.canHaveGeometry`
this (`OBJECTTYPE.allowGeometry = true` or `OBJECTTYPE.allowGeometry`
doesn't exist)
startAt:
type: string
Expand Down
4 changes: 2 additions & 2 deletions src/objects/api/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ components:
nullable: true
description: Point, linestring or polygon object which represents the coordinates
of the object. Geometry can be added only if the related OBJECTTYPE allows
this (`OBJECTTYPE.canHaveGeometry = true` or `OBJECTTYPE.canHaveGeometry`
this (`OBJECTTYPE.allowGeometry = true` or `OBJECTTYPE.allowGeometry`
doesn't exist)
startAt:
type: string
Expand Down Expand Up @@ -868,7 +868,7 @@ components:
nullable: true
description: Point, linestring or polygon object which represents the coordinates
of the object. Geometry can be added only if the related OBJECTTYPE allows
this (`OBJECTTYPE.canHaveGeometry = true` or `OBJECTTYPE.canHaveGeometry`
this (`OBJECTTYPE.allowGeometry = true` or `OBJECTTYPE.allowGeometry`
doesn't exist)
startAt:
type: string
Expand Down
4 changes: 2 additions & 2 deletions src/objects/api/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def __call__(self, attrs):
msg = f"Object type can not be retrieved: {exc.args[0]}"
raise ValidationError(msg)

can_have_geometry = response.get("canHaveGeometry", True)
allow_geometry = response.get("allowGeometry", True)

if geometry and not can_have_geometry:
if geometry and not allow_geometry:
raise serializers.ValidationError(self.message, code=self.code)
2 changes: 1 addition & 1 deletion src/objects/core/migrations/0027_auto_20211203_1209.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Migration(migrations.Migration):
name="geometry",
field=django.contrib.gis.db.models.fields.GeometryField(
blank=True,
help_text="Point, linestring or polygon object which represents the coordinates of the object. Geometry can be added only if the related OBJECTTYPE allows this (`OBJECTTYPE.canHaveGeometry = true` or `OBJECTTYPE.canHaveGeometry` doesn't exist)",
help_text="Point, linestring or polygon object which represents the coordinates of the object. Geometry can be added only if the related OBJECTTYPE allows this (`OBJECTTYPE.allowGeometry = true` or `OBJECTTYPE.allowGeometry` doesn't exist)",
null=True,
srid=4326,
verbose_name="geometry",
Expand Down
2 changes: 1 addition & 1 deletion src/objects/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class ObjectRecord(models.Model):
help_text=_(
"Point, linestring or polygon object which represents the coordinates of the "
"object. Geometry can be added only if the related OBJECTTYPE allows this "
"(`OBJECTTYPE.canHaveGeometry = true` or `OBJECTTYPE.canHaveGeometry` doesn't "
"(`OBJECTTYPE.allowGeometry = true` or `OBJECTTYPE.allowGeometry` doesn't "
"exist)"
),
)
Expand Down
2 changes: 1 addition & 1 deletion src/objects/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def mock_objecttype(url: str, attrs=None) -> dict:
"labels": {},
"createdAt": "2020-12-01",
"modifiedAt": "2020-12-01",
"canHaveGeometry": True,
"allowGeometry": True,
"versions": [
f"{url}/versions/1",
],
Expand Down
14 changes: 5 additions & 9 deletions src/objects/tests/v1/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,7 @@ def test_create_object_geometry_not_allowed(self, m):
)
m.get(
self.object_type.url,
json=mock_objecttype(
self.object_type.url, attrs={"canHaveGeometry": False}
),
json=mock_objecttype(self.object_type.url, attrs={"allowGeometry": False}),
)

url = reverse("object-list")
Expand All @@ -209,11 +207,11 @@ def test_create_object_geometry_not_allowed(self, m):
["This object type doesn't support geometry"],
)

def test_create_object_with_geometry_without_canHaveGeometry(self, m):
"""test the support of Objecttypes api without canHaveGeometry property"""
def test_create_object_with_geometry_without_allowGeometry(self, m):
"""test the support of Objecttypes api without allowGeometry property"""
mock_service_oas_get(m, OBJECT_TYPES_API, "objecttypes")
object_type_response = mock_objecttype(self.object_type.url)
del object_type_response["canHaveGeometry"]
del object_type_response["allowGeometry"]
m.get(self.object_type.url, json=object_type_response)
m.get(
f"{self.object_type.url}/versions/1",
Expand Down Expand Up @@ -329,9 +327,7 @@ def test_update_geometry_not_allowed(self, m):
)
m.get(
self.object_type.url,
json=mock_objecttype(
self.object_type.url, attrs={"canHaveGeometry": False}
),
json=mock_objecttype(self.object_type.url, attrs={"allowGeometry": False}),
)

initial_record = ObjectRecordFactory.create(
Expand Down
14 changes: 5 additions & 9 deletions src/objects/tests/v2/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,7 @@ def test_create_object_geometry_not_allowed(self, m):
)
m.get(
self.object_type.url,
json=mock_objecttype(
self.object_type.url, attrs={"canHaveGeometry": False}
),
json=mock_objecttype(self.object_type.url, attrs={"allowGeometry": False}),
)

url = reverse("object-list")
Expand All @@ -209,11 +207,11 @@ def test_create_object_geometry_not_allowed(self, m):
["This object type doesn't support geometry"],
)

def test_create_object_with_geometry_without_canHaveGeometry(self, m):
"""test the support of Objecttypes api without canHaveGeometry property"""
def test_create_object_with_geometry_without_allowGeometry(self, m):
"""test the support of Objecttypes api without allowGeometry property"""
mock_service_oas_get(m, OBJECT_TYPES_API, "objecttypes")
object_type_response = mock_objecttype(self.object_type.url)
del object_type_response["canHaveGeometry"]
del object_type_response["allowGeometry"]
m.get(self.object_type.url, json=object_type_response)
m.get(
f"{self.object_type.url}/versions/1",
Expand Down Expand Up @@ -329,9 +327,7 @@ def test_update_geometry_not_allowed(self, m):
)
m.get(
self.object_type.url,
json=mock_objecttype(
self.object_type.url, attrs={"canHaveGeometry": False}
),
json=mock_objecttype(self.object_type.url, attrs={"allowGeometry": False}),
)

initial_record = ObjectRecordFactory.create(
Expand Down

0 comments on commit 28789a8

Please sign in to comment.