From 12139d5bed7fef3e41f5f7ac6d02309126bb26d9 Mon Sep 17 00:00:00 2001 From: Denis Rouzaud Date: Tue, 16 Dec 2025 15:34:42 +0100 Subject: [PATCH] add model to test mandatory field --- scripts/run_tests_locally.sh | 1 + .../tests/management/commands/populate_users.py | 1 + .../tests/migrations/0001_initial.py | 13 ++++++++++--- tests/django_oapif_tests/tests/models.py | 6 ++++++ tests/django_oapif_tests/tests/ogc.py | 9 +++++++++ 5 files changed, 27 insertions(+), 3 deletions(-) mode change 100644 => 100755 scripts/run_tests_locally.sh diff --git a/scripts/run_tests_locally.sh b/scripts/run_tests_locally.sh old mode 100644 new mode 100755 index 2ff248c5..8e4738d2 --- a/scripts/run_tests_locally.sh +++ b/scripts/run_tests_locally.sh @@ -5,6 +5,7 @@ export COMPOSE_FILE=tests/docker-compose.yml:tests/docker-compose.dev.yml:tests/ #docker compose --profile testing_integration up --build -d docker compose down -v || true docker compose up --build -d +docker compose exec django python manage.py makemigrations docker compose exec django python manage.py migrate --no-input docker compose exec django python manage.py populate_users docker compose exec django python manage.py populate_data diff --git a/tests/django_oapif_tests/tests/management/commands/populate_users.py b/tests/django_oapif_tests/tests/management/commands/populate_users.py index ebe50a69..75ebb9b8 100644 --- a/tests/django_oapif_tests/tests/management/commands/populate_users.py +++ b/tests/django_oapif_tests/tests/management/commands/populate_users.py @@ -21,6 +21,7 @@ def handle(self, *args, **options): "line_2056_10fields", "polygon_2056", "secretlayer", + "mandatoryfield", ): adding.append(Permission.objects.get(codename=f"add_{model}")) modifying.append(Permission.objects.get(codename=f"change_{model}")) diff --git a/tests/django_oapif_tests/tests/migrations/0001_initial.py b/tests/django_oapif_tests/tests/migrations/0001_initial.py index e871b4a6..20e66b9b 100644 --- a/tests/django_oapif_tests/tests/migrations/0001_initial.py +++ b/tests/django_oapif_tests/tests/migrations/0001_initial.py @@ -1,8 +1,7 @@ -# Generated by Django 4.2.11 on 2024-03-23 05:08 - -import uuid +# Generated by Django 5.2.9 on 2025-12-16 14:18 import django.contrib.gis.db.models.fields +import uuid from django.db import migrations, models @@ -36,6 +35,14 @@ class Migration(migrations.Migration): 'abstract': False, }, ), + migrations.CreateModel( + name='MandatoryField', + fields=[ + ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), + ('text_mandatory_field', models.CharField(max_length=255, verbose_name='Mandatory Field')), + ('geom', django.contrib.gis.db.models.fields.PointField(srid=2056, verbose_name='Geometry')), + ], + ), migrations.CreateModel( name='NoGeom_100fields', fields=[ diff --git a/tests/django_oapif_tests/tests/models.py b/tests/django_oapif_tests/tests/models.py index 1ea5a8f3..e55bb7b2 100644 --- a/tests/django_oapif_tests/tests/models.py +++ b/tests/django_oapif_tests/tests/models.py @@ -139,3 +139,9 @@ class Polygon_2056(models.Model): class SecretLayer(BaseModelWithTenFields): geom = models.PointField(srid=2056, verbose_name=_("Geometry")) + + +class MandatoryField(models.Model): + id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) + text_mandatory_field = models.CharField(max_length=255, verbose_name=_("Mandatory Field"), null=False, blank=False) + geom = models.PointField(srid=2056, verbose_name=_("Geometry")) diff --git a/tests/django_oapif_tests/tests/ogc.py b/tests/django_oapif_tests/tests/ogc.py index a120cc6e..2ea82db9 100644 --- a/tests/django_oapif_tests/tests/ogc.py +++ b/tests/django_oapif_tests/tests/ogc.py @@ -8,6 +8,7 @@ Point_2056_10fields, Polygon_2056, SecretLayer, + MandatoryField, ) ogc_api = OAPIF() @@ -72,3 +73,11 @@ ], handler=DjangoModelPermissionsHandler, ) + +ogc_api.register( + MandatoryField, + title="mandatory_field", + properties_fields=[ + "text_mandatory_field", + ], +)