-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c7e4837
commit 46f6381
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
57 changes: 57 additions & 0 deletions
57
src/openforms/registrations/contrib/json/tests/test_backend.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |