Bump version to 1.3.6 and update NEWS.rst for 1.3.5
[mailman-postorious.git] / src / postorius / tests / test_validators.py
blob54562085fc741a15f01ebeb54db23496eaecc5f8
1 from django.core.exceptions import ValidationError
3 import pytest
5 from postorius.forms.validators import validate_uuid_or_email
8 class TestValidators:
10 def test_validate_uuid_or_email(self):
11 # Test valid email.
12 emails = ['aperson@example.com', 'user@localhost', 'bp@localhost.com']
13 for email in emails:
14 assert validate_uuid_or_email(email) == email
15 # Test invalid email uuid.
16 uuids = ['00000000000000000000000000000034',
17 '00000000000000000000000000000084']
18 for uuid in uuids:
19 assert validate_uuid_or_email(uuid) == uuid
21 # Test invalid email.
22 invalid_emails = [
23 'missingdomain@', '@missinglocal', 'mis2']
24 for email in invalid_emails:
25 with pytest.raises(ValidationError):
26 validate_uuid_or_email(email)
27 # Test invalid uuid.
28 invalid_uuids = ['02394', '0923402340000000023']
29 for uuid in invalid_uuids:
30 with pytest.raises(ValidationError):
31 validate_uuid_or_email(uuid)