-
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
d9b5b7f
commit 8190297
Showing
3 changed files
with
127 additions
and
12 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
|
@@ -754,3 +754,119 @@ def test_submission_completed_incomplete_appointment(self): | |
|
||
with self.assertRaises(AppointmentRegistrationFailed): | ||
on_post_submission_event(submission.id) | ||
|
||
def test_cosign_not_required_and_not_filled_in_proceeds_with_registration(self): | ||
submission = SubmissionFactory.from_components( | ||
components_list=[ | ||
{ | ||
"key": "email", | ||
"type": "email", | ||
"label": "Email", | ||
"confirmationRecipient": True, | ||
}, | ||
{ | ||
"key": "cosign", | ||
"type": "cosign", | ||
"label": "Cosign component", | ||
"validate": {"required": False}, | ||
}, | ||
], | ||
submitted_data={"cosign": "", "email": "[email protected]"}, | ||
completed=True, | ||
cosign_complete=False, | ||
form__registration_backend="email", | ||
form__registration_backend_options={"to_emails": ["[email protected]"]}, | ||
form__name="Pretty Form", | ||
auth_info__attribute=AuthAttribute.bsn, | ||
auth_info__value="111222333", | ||
) | ||
|
||
with patch( | ||
"openforms.registrations.contrib.email.plugin.EmailRegistration.register_submission" | ||
) as mock_registration, patch( | ||
"openforms.registrations.contrib.email.plugin.EmailRegistration.update_payment_status" | ||
) as mock_payment_status_update: | ||
on_post_submission_event(submission.id) | ||
|
||
mock_registration.assert_called_once() | ||
mock_payment_status_update.assert_not_called() | ||
|
||
mails = mail.outbox | ||
|
||
self.assertEqual(1, len(mails)) # No cosign request email! | ||
self.assertEqual( | ||
mails[0].subject, _("Bevestiging van uw inzending van Pretty Form") | ||
) | ||
self.assertEqual(mails[0].to, ["[email protected]"]) | ||
self.assertEqual(mails[0].cc, []) | ||
|
||
cosign_info = _( | ||
"This form will not be processed until it has been co-signed. A co-sign request was sent to %(cosigner_email)s." | ||
) % {"cosigner_email": "[email protected]"} | ||
|
||
self.assertNotIn(cosign_info, mails[0].body.strip("\n")) | ||
|
||
submission.refresh_from_db() | ||
|
||
self.assertFalse(submission.cosign_request_email_sent) | ||
self.assertTrue(submission.confirmation_email_sent) | ||
self.assertNotEqual(submission.auth_info.value, "111222333") | ||
|
||
def test_cosign_not_required_but_filled_in_does_not_proceed_with_registration(self): | ||
submission = SubmissionFactory.from_components( | ||
components_list=[ | ||
{ | ||
"key": "email", | ||
"type": "email", | ||
"label": "Email", | ||
"confirmationRecipient": True, | ||
}, | ||
{ | ||
"key": "cosign", | ||
"type": "cosign", | ||
"label": "Cosign component", | ||
"validate": {"required": False}, | ||
}, | ||
], | ||
submitted_data={"cosign": "[email protected]", "email": "[email protected]"}, | ||
completed=True, | ||
cosign_complete=False, | ||
form__registration_backend="email", | ||
form__registration_backend_options={"to_emails": ["[email protected]"]}, | ||
form__name="Pretty Form", | ||
auth_info__attribute=AuthAttribute.bsn, | ||
auth_info__value="111222333", | ||
) | ||
|
||
with patch( | ||
"openforms.registrations.contrib.email.plugin.EmailRegistration.register_submission" | ||
) as mock_registration, patch( | ||
"openforms.registrations.contrib.email.plugin.EmailRegistration.update_payment_status" | ||
) as mock_payment_status_update: | ||
on_post_submission_event(submission.id) | ||
|
||
mock_registration.assert_not_called() | ||
mock_payment_status_update.assert_not_called() | ||
|
||
mails = mail.outbox | ||
|
||
self.assertEqual(2, len(mails)) | ||
self.assertEqual(mails[0].subject, _("Co-sign request for Pretty Form")) | ||
self.assertEqual(mails[0].to, ["[email protected]"]) | ||
self.assertEqual( | ||
mails[1].subject, _("Bevestiging van uw inzending van Pretty Form") | ||
) | ||
self.assertEqual(mails[1].to, ["[email protected]"]) | ||
self.assertEqual(mails[1].cc, []) | ||
|
||
cosign_info = _( | ||
"This form will not be processed until it has been co-signed. A co-sign request was sent to %(cosigner_email)s." | ||
) % {"cosigner_email": "[email protected]"} | ||
|
||
self.assertIn(cosign_info, mails[1].body.strip("\n")) | ||
|
||
submission.refresh_from_db() | ||
|
||
self.assertTrue(submission.cosign_request_email_sent) | ||
self.assertTrue(submission.confirmation_email_sent) | ||
self.assertEqual(submission.auth_info.value, "111222333") |
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