From 20cb7d0c917d098e32e73c46d11cb8399fd470e3 Mon Sep 17 00:00:00 2001 From: Sergei Maertens Date: Wed, 4 Dec 2024 17:50:43 +0100 Subject: [PATCH] :label: [#4398] Fix type errors in Objects API tests --- .../contrib/objects_api/tests/test_backend.py | 7 +++++++ .../objects_api/tests/test_backend_v1.py | 18 ++++++++++++++++++ .../objects_api/tests/test_backend_v2.py | 18 ++++++++++++++++++ .../objects_api/tests/test_serializer.py | 4 +++- 4 files changed, 46 insertions(+), 1 deletion(-) diff --git a/src/openforms/registrations/contrib/objects_api/tests/test_backend.py b/src/openforms/registrations/contrib/objects_api/tests/test_backend.py index 9c68a58e75..3000483a33 100644 --- a/src/openforms/registrations/contrib/objects_api/tests/test_backend.py +++ b/src/openforms/registrations/contrib/objects_api/tests/test_backend.py @@ -298,6 +298,7 @@ def test_submission_with_objects_api_backend_create_and_update_object(self): "objecttype_version": 3, "objects_api_group": objects_api_group, "update_existing_object": False, + "auth_attribute_path": [], }, ) @@ -328,6 +329,7 @@ def test_submission_with_objects_api_backend_create_and_update_object(self): "objecttype_version": 3, "objects_api_group": objects_api_group, "update_existing_object": True, + "auth_attribute_path": ["bsn"], }, ) @@ -364,6 +366,7 @@ def test_submission_with_objects_api_backend_create_and_update_object(self): "objecttype_version": 3, "objects_api_group": objects_api_group, "update_existing_object": False, + "auth_attribute_path": [], }, ) @@ -393,6 +396,7 @@ def test_submission_with_objects_api_backend_create_and_update_object(self): "objecttype_version": 3, "objects_api_group": objects_api_group, "update_existing_object": True, + "auth_attribute_path": ["bsn"], }, ) @@ -447,6 +451,7 @@ def test_prefer_dynamic_resolution_over_fixed_url(self): "objecttype": UUID("527b8408-7421-4808-a744-43ccb7bdaaa2"), "objecttype_version": 1, "update_existing_object": False, + "auth_attribute_path": [], "variables_mapping": [ { "variable_key": "attachment", @@ -517,6 +522,7 @@ def test_create_document_documenttype_dynamically_resolved(self): "objecttype": UUID("527b8408-7421-4808-a744-43ccb7bdaaa2"), "objecttype_version": 1, "update_existing_object": False, + "auth_attribute_path": [], "variables_mapping": [ { "variable_key": "attachment", @@ -580,6 +586,7 @@ def test_allow_registration_with_unpublished_document_types(self): "objecttype": UUID("527b8408-7421-4808-a744-43ccb7bdaaa2"), "objecttype_version": 1, "update_existing_object": False, + "auth_attribute_path": [], "variables_mapping": [ { "variable_key": "attachment", diff --git a/src/openforms/registrations/contrib/objects_api/tests/test_backend_v1.py b/src/openforms/registrations/contrib/objects_api/tests/test_backend_v1.py index 7a64947a81..03f050cadf 100644 --- a/src/openforms/registrations/contrib/objects_api/tests/test_backend_v1.py +++ b/src/openforms/registrations/contrib/objects_api/tests/test_backend_v1.py @@ -147,6 +147,7 @@ def test_submission_with_objects_api_backend_override_defaults(self): "objecttype_version": 1, "productaanvraag_type": "testproduct", "update_existing_object": False, + "auth_attribute_path": [], # `omschrijving` "PDF Informatieobjecttype other catalog": "informatieobjecttype_submission_report": "http://localhost:8003/catalogi/api/v1/informatieobjecttypen/f2908f6f-aa07-42ef-8760-74c5234f2d25", "upload_submission_csv": True, @@ -240,6 +241,7 @@ def test_submission_with_objects_api_backend_override_defaults_upload_csv_defaul "informatieobjecttype_submission_report": "http://localhost:8003/catalogi/api/v1/informatieobjecttypen/f2908f6f-aa07-42ef-8760-74c5234f2d25", "upload_submission_csv": True, "update_existing_object": False, + "auth_attribute_path": [], "organisatie_rsin": "123456782", "zaak_vertrouwelijkheidaanduiding": "geheim", "doc_vertrouwelijkheidaanduiding": "geheim", @@ -297,6 +299,7 @@ def test_submission_with_objects_api_backend_override_defaults_do_not_upload_csv "objects_api_group": self.objects_api_group, "upload_submission_csv": False, "update_existing_object": False, + "auth_attribute_path": [], }, ) @@ -329,6 +332,7 @@ def test_submission_with_objects_api_backend_missing_csv_iotype(self): "objects_api_group": self.objects_api_group, "upload_submission_csv": True, "update_existing_object": False, + "auth_attribute_path": [], "informatieobjecttype_submission_csv": "", }, ) @@ -374,6 +378,7 @@ def test_submission_with_objects_api_backend_override_content_json(self): "objects_api_group": self.objects_api_group, "upload_submission_csv": False, "update_existing_object": False, + "auth_attribute_path": [], "content_json": textwrap.dedent( """ { @@ -438,6 +443,7 @@ def test_submission_with_objects_api_backend_use_config_defaults(self): "objecttype": UUID("8faed0fa-7864-4409-aa6d-533a37616a9e"), "objecttype_version": 1, "update_existing_object": False, + "auth_attribute_path": [], }, ) @@ -513,6 +519,7 @@ def test_submission_with_objects_api_backend_attachments(self): "objecttype": UUID("8faed0fa-7864-4409-aa6d-533a37616a9e"), "objecttype_version": 1, "update_existing_object": False, + "auth_attribute_path": [], }, ) @@ -623,6 +630,7 @@ def test_submission_with_objects_api_backend_attachments_specific_iotypen(self): "objecttype": UUID("8faed0fa-7864-4409-aa6d-533a37616a9e"), "objecttype_version": 1, "update_existing_object": False, + "auth_attribute_path": [], }, ) @@ -719,6 +727,7 @@ def test_submission_with_objects_api_backend_attachments_component_overwrites(se "objecttype": UUID("8faed0fa-7864-4409-aa6d-533a37616a9e"), "objecttype_version": 1, "update_existing_object": False, + "auth_attribute_path": [], }, ) @@ -802,6 +811,7 @@ def test_submission_with_objects_api_backend_attachments_component_inside_fields "objecttype": UUID("8faed0fa-7864-4409-aa6d-533a37616a9e"), "objecttype_version": 1, "update_existing_object": False, + "auth_attribute_path": [], }, ) @@ -861,6 +871,7 @@ def test_submission_with_objects_api_escapes_html(self): "content_json": content_template, "upload_submission_csv": False, "update_existing_object": False, + "auth_attribute_path": [], }, ) @@ -906,6 +917,7 @@ def test_submission_with_payment(self): "objecttype": UUID("8faed0fa-7864-4409-aa6d-533a37616a9e"), "objecttype_version": 1, "update_existing_object": False, + "auth_attribute_path": [], }, ) @@ -943,6 +955,7 @@ def test_submission_with_auth_context_data(self): "informatieobjecttype_submission_report": "", "upload_submission_csv": False, "update_existing_object": False, + "auth_attribute_path": [], "content_json": r"""{"auth": {% as_json variables.auth_context %}}""", }, ) @@ -1003,6 +1016,7 @@ def test_submission_with_auth_context_data_not_authenticated(self): "informatieobjecttype_submission_report": "", "upload_submission_csv": False, "update_existing_object": False, + "auth_attribute_path": [], "content_json": r"""{"auth": {% as_json variables.auth_context %}}""", }, ) @@ -1057,6 +1071,7 @@ def test_cosign_info_available(self): "objecttype_version": 1, "productaanvraag_type": "-dummy-", "update_existing_object": False, + "auth_attribute_path": [], "content_json": textwrap.dedent( """ { @@ -1103,6 +1118,7 @@ def test_cosign_info_not_available(self): "objecttype_version": 1, "productaanvraag_type": "-dummy-", "update_existing_object": False, + "auth_attribute_path": [], "content_json": textwrap.dedent( """ { @@ -1152,6 +1168,7 @@ def test_cosign_info_no_cosign_date(self): "objecttype_version": 1, "productaanvraag_type": "-dummy-", "update_existing_object": False, + "auth_attribute_path": [], "content_json": textwrap.dedent( """ { @@ -1184,6 +1201,7 @@ def test_payment_context_without_any_payment_attempts(self): "objecttype_version": 1, "productaanvraag_type": "-dummy-", "update_existing_object": False, + "auth_attribute_path": [], "content_json": """{"amount": {{ payment.amount }}}""", } handler = ObjectsAPIV1Handler() diff --git a/src/openforms/registrations/contrib/objects_api/tests/test_backend_v2.py b/src/openforms/registrations/contrib/objects_api/tests/test_backend_v2.py index 4eadb72bdb..d1a163e5f3 100644 --- a/src/openforms/registrations/contrib/objects_api/tests/test_backend_v2.py +++ b/src/openforms/registrations/contrib/objects_api/tests/test_backend_v2.py @@ -87,6 +87,7 @@ def test_submission_with_objects_api_v2(self): "objecttype_version": 3, "upload_submission_csv": True, "update_existing_object": False, + "auth_attribute_path": [], "informatieobjecttype_submission_report": "http://localhost:8003/catalogi/api/v1/informatieobjecttypen/7a474713-0833-402a-8441-e467c08ac55b", "informatieobjecttype_submission_csv": "http://localhost:8003/catalogi/api/v1/informatieobjecttypen/b2d83b94-9b9b-4e80-a82f-73ff993c62f3", "informatieobjecttype_attachment": "http://localhost:8003/catalogi/api/v1/informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7", @@ -193,6 +194,7 @@ def test_submission_with_objects_api_v2_with_payment_attributes(self): "objecttype_version": 3, "upload_submission_csv": False, "update_existing_object": False, + "auth_attribute_path": [], "variables_mapping": [ { "variable_key": "payment_completed", @@ -293,6 +295,7 @@ def test_submission_with_file_components(self): "objecttype_version": 1, "upload_submission_csv": False, "update_existing_object": False, + "auth_attribute_path": [], "informatieobjecttype_attachment": "http://localhost:8003/catalogi/api/v1/informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7", "organisatie_rsin": "000000000", "variables_mapping": [ @@ -369,6 +372,7 @@ def test_submission_with_file_components_container_variable(self): "objecttype_version": 1, "upload_submission_csv": False, "update_existing_object": False, + "auth_attribute_path": [], "informatieobjecttype_attachment": "http://localhost:8003/catalogi/api/v1/informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7", "organisatie_rsin": "000000000", "variables_mapping": [ @@ -415,6 +419,7 @@ def test_submission_with_empty_optional_file(self): "objecttype_version": 1, "upload_submission_csv": False, "update_existing_object": False, + "auth_attribute_path": [], "informatieobjecttype_attachment": "http://localhost:8003/catalogi/api/v1/informatieobjecttypen/531f6c1a-97f7-478c-85f0-67d2f23661c7", "organisatie_rsin": "000000000", "variables_mapping": [ @@ -475,6 +480,7 @@ def test_addressNl_legacy_before_of_30(self): "objecttype": "8faed0fa-7864-4409-aa6d-533a37616a9e", "objecttype_version": 1, "update_existing_object": False, + "auth_attribute_path": [], "variables_mapping": [ { "variable_key": "addressNl", @@ -549,6 +555,7 @@ def test_submission_with_map_component_inside_data(self): "objecttype": UUID("f3f1b370-97ed-4730-bc7e-ebb20c230377"), "objecttype_version": 1, "update_existing_object": False, + "auth_attribute_path": [], "variables_mapping": [ { "variable_key": "location", @@ -596,6 +603,7 @@ def test_layout_components(self): "objecttype": UUID("f3f1b370-97ed-4730-bc7e-ebb20c230377"), "objecttype_version": 1, "update_existing_object": False, + "auth_attribute_path": [], "variables_mapping": [ { "variable_key": "fieldset.textfield", @@ -639,6 +647,7 @@ def test_hidden_component(self): "objecttype": UUID("f3f1b370-97ed-4730-bc7e-ebb20c230377"), "objecttype_version": 1, "update_existing_object": False, + "auth_attribute_path": [], "variables_mapping": [ { "variable_key": "textfield", @@ -670,6 +679,7 @@ def test_public_reference_available(self): "objecttype": UUID("f3f1b370-97ed-4730-bc7e-ebb20c230377"), "objecttype_version": 1, "update_existing_object": False, + "auth_attribute_path": [], "variables_mapping": [ { "variable_key": "public_reference", @@ -716,6 +726,7 @@ def test_cosign_info_available(self): "objecttype": UUID("f3f1b370-97ed-4730-bc7e-ebb20c230377"), "objecttype_version": 1, "update_existing_object": False, + "auth_attribute_path": [], "variables_mapping": [ { "variable_key": "cosign_data", @@ -778,6 +789,7 @@ def test_cosign_info_not_available(self): "objecttype": UUID("f3f1b370-97ed-4730-bc7e-ebb20c230377"), "objecttype_version": 1, "update_existing_object": False, + "auth_attribute_path": [], "variables_mapping": [ { "variable_key": "cosign_date", @@ -833,6 +845,7 @@ def test_cosign_info_no_cosign_date(self): "objecttype": UUID("f3f1b370-97ed-4730-bc7e-ebb20c230377"), "objecttype_version": 1, "update_existing_object": False, + "auth_attribute_path": [], "variables_mapping": [ { "variable_key": "cosign_date", @@ -872,6 +885,7 @@ def test_auth_context_data_info_available(self): "objecttype": UUID("f3f1b370-97ed-4730-bc7e-ebb20c230377"), "objecttype_version": 1, "update_existing_object": False, + "auth_attribute_path": [], "variables_mapping": [ { "variable_key": "auth_context", @@ -983,6 +997,7 @@ def test_auth_context_data_info_parts_missing_variants(self): "objecttype": UUID("f3f1b370-97ed-4730-bc7e-ebb20c230377"), "objecttype_version": 1, "update_existing_object": False, + "auth_attribute_path": [], "variables_mapping": [ { "variable_key": "auth_context", @@ -1142,6 +1157,7 @@ def test_addressNl_with_specific_target_paths(self): "objecttype": UUID("f3f1b370-97ed-4730-bc7e-ebb20c230377"), "objecttype_version": 1, "update_existing_object": False, + "auth_attribute_path": [], "variables_mapping": [ { "variable_key": "addressNl", @@ -1208,6 +1224,7 @@ def test_addressNl_with_specific_target_paths_mapped_and_empty_submitted_data( "objecttype": UUID("f3f1b370-97ed-4730-bc7e-ebb20c230377"), "objecttype_version": 1, "update_existing_object": False, + "auth_attribute_path": [], "variables_mapping": [ { "variable_key": "addressNl", @@ -1270,6 +1287,7 @@ def test_addressNl_with_object_target_path(self): "objecttype": UUID("f3f1b370-97ed-4730-bc7e-ebb20c230377"), "objecttype_version": 1, "update_existing_object": False, + "auth_attribute_path": [], "variables_mapping": [ {"variable_key": "addressNl", "target_path": ["addressNL"]} ], diff --git a/src/openforms/registrations/contrib/objects_api/tests/test_serializer.py b/src/openforms/registrations/contrib/objects_api/tests/test_serializer.py index de84b30108..1d613f5e9b 100644 --- a/src/openforms/registrations/contrib/objects_api/tests/test_serializer.py +++ b/src/openforms/registrations/contrib/objects_api/tests/test_serializer.py @@ -200,7 +200,9 @@ def test_auth_attribute_path_required_if_update_existing_object_is_true(self): }, ) - self.assertFalse(options.is_valid()) + result = options.is_valid() + + self.assertFalse(result) self.assertIn("auth_attribute_path", options.errors) error = options.errors["auth_attribute_path"][0] self.assertEqual(error.code, "required")