1 from django
.core
.exceptions
import ValidationError
5 from postorius
.forms
.validators
import validate_uuid_or_email
10 def test_validate_uuid_or_email(self
):
12 emails
= ['aperson@example.com', 'user@localhost', 'bp@localhost.com']
14 assert validate_uuid_or_email(email
) == email
15 # Test invalid email uuid.
16 uuids
= ['00000000000000000000000000000034',
17 '00000000000000000000000000000084']
19 assert validate_uuid_or_email(uuid
) == uuid
23 'missingdomain@', '@missinglocal', 'mis2']
24 for email
in invalid_emails
:
25 with pytest
.raises(ValidationError
):
26 validate_uuid_or_email(email
)
28 invalid_uuids
= ['02394', '0923402340000000023']
29 for uuid
in invalid_uuids
:
30 with pytest
.raises(ValidationError
):
31 validate_uuid_or_email(uuid
)