-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#3688] Add a
objecttypes_service
field, add tests
- Loading branch information
Showing
3 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
...registrations/contrib/objects_api/migrations/0010_objectsapiconfig_objecttypes_service.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Generated by Django 3.2.23 on 2024-01-31 14:16 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("zgw_consumers", "0019_alter_service_uuid"), | ||
( | ||
"registrations_objects_api", | ||
"0009_objectsapiconfig_payment_status_update_json", | ||
), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="objectsapiconfig", | ||
name="objecttypes_service", | ||
field=models.OneToOneField( | ||
limit_choices_to={"api_type": "orc"}, | ||
null=True, | ||
on_delete=django.db.models.deletion.PROTECT, | ||
related_name="+", | ||
to="zgw_consumers.service", | ||
verbose_name="Objecttypes API", | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/openforms/registrations/contrib/objects_api/tests/test_models.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from django.core.exceptions import ValidationError | ||
from django.test import TestCase | ||
|
||
from zgw_consumers.constants import APITypes | ||
|
||
from zgw_consumers_ext.tests.factories import ServiceFactory | ||
|
||
from ..models import ObjectsAPIConfig | ||
|
||
|
||
class ObjectsAPIConfigTests(TestCase): | ||
|
||
def test_invalid_objecttypes_url(self): | ||
config = ObjectsAPIConfig( | ||
objecttypes_service=ServiceFactory.build( | ||
api_root="https://objecttypen.nl/api/v1/", | ||
api_type=APITypes.orc, | ||
), | ||
objecttype="https://example.com/api/dummy/", | ||
) | ||
|
||
self.assertRaises(ValidationError, config.clean) | ||
|
||
def test_valid_objecttypes_url(self): | ||
config = ObjectsAPIConfig( | ||
objecttypes_service=ServiceFactory.build( | ||
api_root="https://objecttypen.nl/api/v1/", | ||
api_type=APITypes.orc, | ||
), | ||
objecttype="https://objecttypen.nl/api/v1/objecttypes/1", | ||
) | ||
|
||
try: | ||
config.clean() | ||
except ValidationError as e: | ||
self.fail(f"Unexpected exception : {e}") |