Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add validate TLD optional parameter in validate email #390

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions post_office/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@ def test_email_validator(self):

# Should also support international domains
validate_email_with_name('Alice Bob <[email protected]>')
validate_email_with_name('[email protected]', validate_tld=True)

# These should raise ValidationError
self.assertRaises(ValidationError, validate_email_with_name, 'invalid')
self.assertRaises(ValidationError, validate_email_with_name, 'Al <ab>')
self.assertRaises(ValidationError, validate_email_with_name, 'Al <>')
self.assertRaises(ValidationError, validate_email_with_name, '[email protected]', validate_tld=True)
self.assertRaises(ValidationError, validate_email_with_name, 'Al <[email protected]>', validate_tld=True)
self.assertRaises(ValidationError, validate_email_with_name, '[email protected]', validate_tld=True)

def test_comma_separated_email_list_validator(self):
# These should validate
Expand All @@ -57,6 +61,9 @@ def test_comma_separated_email_list_validator(self):
# These should raise ValidationError
self.assertRaises(ValidationError, validate_comma_separated_emails,
['[email protected]', 'invalid_mail', '[email protected]'])
self.assertRaises(ValidationError, validate_comma_separated_emails,
['[email protected]', '[email protected]', '[email protected]'],
validate_tld=True)

def test_get_template_email(self):
# Sanity Check
Expand Down
Loading