-
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.
[#5039] Changed email registration nonField errors to specific fields…
… errors
- Loading branch information
Showing
3 changed files
with
76 additions
and
15 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
48 changes: 48 additions & 0 deletions
48
src/openforms/registrations/contrib/email/tests/test_serializers.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,48 @@ | ||
from django.test import TestCase | ||
|
||
from ..config import EmailOptionsSerializer | ||
|
||
|
||
class EmailOptionsSerializerTest(TestCase): | ||
def test_email_and_text_content_fields(self): | ||
with self.subTest("both fields missing"): | ||
serializer = EmailOptionsSerializer( | ||
data={ | ||
"to_emails": ["[email protected]"], | ||
"email_content_template_html": "", | ||
"email_content_template_text": "", | ||
}, | ||
context={"request": None}, | ||
) | ||
|
||
self.assertTrue(serializer.is_valid()) | ||
|
||
with self.subTest("text is missing"): | ||
serializer = EmailOptionsSerializer( | ||
data={ | ||
"to_emails": ["[email protected]"], | ||
"email_content_template_html": "<p>some text</p>", | ||
"email_content_template_text": "", | ||
}, | ||
context={"request": None}, | ||
) | ||
|
||
self.assertFalse(serializer.is_valid()) | ||
self.assertEqual( | ||
serializer.errors["email_content_template_text"][0].code, "required" | ||
) | ||
|
||
with self.subTest("html is missing"): | ||
serializer = EmailOptionsSerializer( | ||
data={ | ||
"to_emails": ["[email protected]"], | ||
"email_content_template_html": "", | ||
"email_content_template_text": "some text", | ||
}, | ||
context={"request": None}, | ||
) | ||
|
||
self.assertFalse(serializer.is_valid()) | ||
self.assertEqual( | ||
serializer.errors["email_content_template_html"][0].code, "required" | ||
) |