Skip to content

Commit

Permalink
[#4516] PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Viicos committed Jul 17, 2024
1 parent ccd4078 commit 578d43f
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions src/openforms/forms/tests/test_import_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -1430,9 +1430,14 @@ def test_import_form_with_objects_registration_backend_no_group(self):
for name, data in resources.items():
zip_file.writestr(f"{name}.json", json.dumps(data))

with self.assertRaises(CommandError):
with self.assertRaises(CommandError) as exc:
call_command("import", import_file=self.filepath)

error_detail = exc.exception.args[0].detail["registration_backends"][0][
"options"
]["objects_api_group"][0]
self.assertEqual(error_detail.code, "invalid")

def test_import_form_with_objects_registration_backend_no_matching_group(self):
resources = {
"forms": [
Expand All @@ -1459,15 +1464,25 @@ def test_import_form_with_objects_registration_backend_no_matching_group(self):
}

# no matching groups:
ObjectsAPIGroupConfigFactory.create_batch(2)
ObjectsAPIGroupConfigFactory.create(
objecttypes_service__api_root="http://example1.com"
)
ObjectsAPIGroupConfigFactory.create(
objecttypes_service__api_root="http://example2.com"
)

with zipfile.ZipFile(self.filepath, "w") as zip_file:
for name, data in resources.items():
zip_file.writestr(f"{name}.json", json.dumps(data))

with self.assertRaises(CommandError):
with self.assertRaises(CommandError) as exc:
call_command("import", import_file=self.filepath)

error_detail = exc.exception.args[0].detail["registration_backends"][0][
"options"
]["objects_api_group"][0]
self.assertEqual(error_detail.code, "invalid")

def test_import_form_with_objects_registration_backend_available_group(self):
resources = {
"forms": [
Expand Down Expand Up @@ -1640,9 +1655,14 @@ def test_import_form_with_zgw_registration_backend_no_available_group(self):
for name, data in resources.items():
zip_file.writestr(f"{name}.json", json.dumps(data))

with self.assertRaises(CommandError):
with self.assertRaises(CommandError) as exc:
call_command("import", import_file=self.filepath)

error_detail = exc.exception.args[0].detail["registration_backends"][0][
"options"
]["zgw_api_group"][0]
self.assertEqual(error_detail.code, "invalid")

def test_import_form_with_zgw_registration_backend_available_group(self):
resources = {
"forms": [
Expand Down

0 comments on commit 578d43f

Please sign in to comment.