Skip to content

Commit

Permalink
✅ [#4908] Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
viktorvanwijk committed Dec 19, 2024
1 parent c7e4837 commit 46f6381
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
Empty file.
57 changes: 57 additions & 0 deletions src/openforms/registrations/contrib/json/tests/test_backend.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 46f6381

Please sign in to comment.