Skip to content

Commit

Permalink
add test for not null with default
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed May 23, 2024
1 parent bbd1e28 commit 9cbd62b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/django_oapif_tests/tests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ class Meta:
field_str_9 = models.CharField(max_length=255, verbose_name=_("Field 9"), null=True, blank=True)


@register_oapif_viewset(geom_field=None)
class Non_Null_Field_With_Default(BaseModelWithTenFields):
field_non_null_with_default = models.IntegerField(null=False, blank=False, default=8)


@register_oapif_viewset(crs=2056)
class Point_2056_10fields(BaseModelWithTenFields):
geom = models.PointField(srid=2056, verbose_name=_("Geometry"))
Expand Down
10 changes: 10 additions & 0 deletions tests/django_oapif_tests/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,13 @@ def test_returned_id(self):
location = post_to_items.headers["Location"]
print(location)
self.assertTrue(re.match(r"^.*[0-9a-f\-]{36}$", location))

def test_non_null_with_default(self):
self.client.force_authenticate(user=self.demo_editor)
data = {
"geometry": None,
"properties": None,
}
url = f"{collections_url}/tests.non_null_field_with_default/items"
post_to_items = self.client.post(url, data, format="json")
self.assertIn(post_to_items.status_code, (200, 201), (url, data, post_to_items.data))

0 comments on commit 9cbd62b

Please sign in to comment.