diff --git a/src/openforms/registrations/contrib/json/tests/__init__.py b/src/openforms/registrations/contrib/json/tests/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/openforms/registrations/contrib/json/tests/test_backend.py b/src/openforms/registrations/contrib/json/tests/test_backend.py new file mode 100644 index 0000000000..d27eb55bb4 --- /dev/null +++ b/src/openforms/registrations/contrib/json/tests/test_backend.py @@ -0,0 +1,57 @@ +from django.test import TestCase + +from openforms.appointments.contrib.qmatic.tests.factories import ServiceFactory +from openforms.submissions.public_references import set_submission_reference +from openforms.submissions.tests.factories import ( + SubmissionFactory, + SubmissionFileAttachmentFactory, +) + +from ..plugin import JSONRegistration + + +class JSONBackendTests(TestCase): + # VCR_TEST_FILES = VCR_TEST_FILES + + def test_submission_with_json_backend(self): + submission = SubmissionFactory.from_components( + [ + {"key": "firstName", "type": "textField"}, + {"key": "lastName", "type": "textfield"}, + {"key": "file", "type": "file"}, + ], + completed=True, + submitted_data={ + "firstName": "We Are", + "lastName": "Checking", + "file": [ + { + "url": "some://url", + "name": "my-foo.bin", + "type": "application/foo", + "originalName": "my-foo.bin", + } + ], + }, + bsn=123456789, + ) + + submission_file_attachment = SubmissionFileAttachmentFactory.create( + form_key="file", + submission_step=submission.submissionstep_set.get(), + file_name="my-foo.bin", + content_type="application/foo", + _component_configuration_path="components.2", + _component_data_path="file", + ) + + json_form_options = dict( + service=ServiceFactory(), + relative_api_endpoint="test", + form_variables=["firstName", "lastName", "file", "auth_bsn"], + ) + email_submission = JSONRegistration("json_plugin") + + set_submission_reference(submission) + + email_submission.register_submission(submission, json_form_options)