Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop dependency on gemma-zds-client #4059

Merged
merged 16 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
d12f5a6
:white_check_mark: [#4057] Add test for desired data migration result
sergei-maertens Mar 25, 2024
40fb244
:card_file_box: [#4057] Implement data migration to copy 'global' def…
sergei-maertens Mar 25, 2024
fefdde0
:fire: [#4057] Remove 'global' defaults for zaaktype/informatieobject…
sergei-maertens Mar 25, 2024
4ca2004
:children_crossing: Properly mark objecttype/objecttype version field…
sergei-maertens Mar 25, 2024
80ee3b8
:green_heart: [#4057] Update tests after model/validation changes
sergei-maertens Mar 26, 2024
a8a2f2e
:alien: [#4057] Address breaking changes in zgw-consumers
sergei-maertens Mar 26, 2024
11a645a
:arrow_up: [#4057] Upgrade to zgw-consumers 0.32.0
sergei-maertens Mar 26, 2024
19b6158
:arrow_up: [#4057] Bump extension to version without zds_client import
sergei-maertens Mar 26, 2024
3b19b76
:bento: [#4057] Add more reference data to Open Zaak fixture
sergei-maertens Mar 26, 2024
d881c8a
:truck: [#4057] Split zgw plugin options serializer into separate module
sergei-maertens Mar 26, 2024
07ac5f3
:white_check_mark: [#4057] Test zaaktype URL validation
sergei-maertens Mar 26, 2024
9fc6352
:white_check_mark: [#4057] Test documenttype URL validation
sergei-maertens Mar 26, 2024
6ed79a6
:safety_vest: [#4057] Validate the provided zaaktype/document type ag…
sergei-maertens Mar 26, 2024
0e6e787
:safety_vest: [#4057] Do not validate business logic during registration
sergei-maertens Mar 27, 2024
e4affe2
:recycle: [#4057] Re-write existing tests as VCR tests
sergei-maertens Mar 28, 2024
cbe57e9
:hammer: [#4057] Update release checklist template
sergei-maertens Mar 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 4.2.11 on 2024-03-25 16:45

from django.db import migrations


def move_defaults_from_zgw_api_group_to_backend_options(apps, _):
raise NotImplementedError


class Migration(migrations.Migration):

dependencies = [
("zgw_apis", "0010_zgwapigroupconfig_content_json"),
("forms", "0096_fix_invalid_validate_configuration"),
]

operations = [
migrations.RunPython(
move_defaults_from_zgw_api_group_to_backend_options,
migrations.RunPython.noop,
)
]
147 changes: 147 additions & 0 deletions src/openforms/registrations/contrib/zgw_apis/tests/test_migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,150 @@ def test_no_zgw_api_group_created(self):
solo = ZgwConfig.objects.get()

self.assertIsNone(solo.default_zgw_api_group)


class MoveDefaultsToFormTest(TestMigrations):
app = "zgw_apis"
migrate_from = "0010_zgwapigroupconfig_content_json"
migrate_to = "0011_move_zgw_api_group_defaults_to_form"

def setUpBeforeMigration(self, apps):
ZGWApiGroupConfig = apps.get_model("zgw_apis", "ZGWApiGroupConfig")
ZgwConfig = apps.get_model("zgw_apis", "ZgwConfig")
Service = apps.get_model("zgw_consumers", "Service")
Form = apps.get_model("forms", "Form")
FormRegistrationBackend = apps.get_model("forms", "FormRegistrationBackend")

# create services
zrc = Service.objects.create(
label="Zaak API",
api_root="http://www.example-zrc.com/api/v1/",
api_type=APITypes.zrc,
)
drc = Service.objects.create(
label="Document API",
api_root="http://www.example-drc.com/api/v1/",
api_type=APITypes.drc,
)
ztc = Service.objects.create(
label="Catalogi API",
api_root="http://www.example-ztc.com/api/v1/",
api_type=APITypes.ztc,
)
services = {
"zrc_service": zrc,
"drc_service": drc,
"ztc_service": ztc,
}

# create different config groups & default config
group1 = ZGWApiGroupConfig.objects.create(
zaaktype="http://www.example-ztc.com/api/v1/zaaktypen/1",
informatieobjecttype="http://www.example-ztc.com/api/v1/informatieobjecttypen/1",
**services,
)
group2 = ZGWApiGroupConfig.objects.create(
zaaktype="http://www.example-ztc.com/api/v1/zaaktypen/2",
informatieobjecttype="http://www.example-ztc.com/api/v1/informatieobjecttypen/2",
**services,
)
ZgwConfig.objects.create(default_zgw_api_group=group1)

# form with different backend options
form = Form.objects.create(name="test form")
self.backend1 = FormRegistrationBackend.objects.create(
form=form,
key="global-defaults",
name="global-defaults",
backend="zgw-create-zaak",
options={},
)
self.backend2 = FormRegistrationBackend.objects.create(
form=form,
key="different-group",
name="different-group",
backend="zgw-create-zaak",
options={"zgw_api_group": group2.id},
)
self.backend3 = FormRegistrationBackend.objects.create(
form=form,
key="explicit-types-set",
name="explicit-types-set",
backend="zgw-create-zaak",
options={
"zaaktype": "http://www.example-ztc.com/api/v1/zaaktypen/3",
"informatieobjecttype": "http://www.example-ztc.com/api/v1/informatieobjecttypen/3",
},
)
self.backend4 = FormRegistrationBackend.objects.create(
form=form,
key="explicit-types-set-explicit-group",
name="explicit-types-set-explicit-group",
backend="zgw-create-zaak",
options={
"zgw_api_group": group2.id,
"zaaktype": "http://www.example-ztc.com/api/v1/zaaktypen/3",
"informatieobjecttype": "http://www.example-ztc.com/api/v1/informatieobjecttypen/3",
},
)

def test_defaults_added_to_backends(self):
FormRegistrationBackend = self.apps.get_model(
"forms", "FormRegistrationBackend"
)
backend1 = FormRegistrationBackend.objects.get(id=self.backend1.id)
backend2 = FormRegistrationBackend.objects.get(id=self.backend2.id)
backend3 = FormRegistrationBackend.objects.get(id=self.backend3.id)
backend4 = FormRegistrationBackend.objects.get(id=self.backend4.id)

with self.subTest("backend 1"):
options = backend1.options
self.assertIn("zaaktype", options)
self.assertEqual(
options["zaaktype"], "http://www.example-ztc.com/api/v1/zaaktypen/1"
Viicos marked this conversation as resolved.
Show resolved Hide resolved
)

self.assertIn("informatieobjecttype", options)
self.assertEqual(
options["informatieobjecttype"],
"http://www.example-ztc.com/api/v1/informatieobjecttypen/1",
)

with self.subTest("backend 2"):
options = backend2.options
self.assertIn("zaaktype", options)
self.assertEqual(
options["zaaktype"], "http://www.example-ztc.com/api/v1/zaaktypen/2"
)

self.assertIn("informatieobjecttype", options)
self.assertEqual(
options["informatieobjecttype"],
"http://www.example-ztc.com/api/v1/informatieobjecttypen/2",
)

with self.subTest("backend 3"):
options = backend3.options
self.assertIn("zaaktype", options)
self.assertEqual(
options["zaaktype"], "http://www.example-ztc.com/api/v1/zaaktypen/3"
)

self.assertIn("informatieobjecttype", options)
self.assertEqual(
options["informatieobjecttype"],
"http://www.example-ztc.com/api/v1/informatieobjecttypen/3",
)

with self.subTest("backend 4"):
options = backend4.options
self.assertIn("zaaktype", options)
self.assertEqual(
options["zaaktype"], "http://www.example-ztc.com/api/v1/zaaktypen/3"
)

self.assertIn("informatieobjecttype", options)
self.assertEqual(
options["informatieobjecttype"],
"http://www.example-ztc.com/api/v1/informatieobjecttypen/3",
)