Files
dify/api/tests/unit_tests/libs/test_email.py
T
2024-06-17 21:32:59 +08:00

26 lines
787 B
Python

from libs.helper import email
def test_email_with_valid_email():
assert email("[email protected]") == "[email protected]"
assert email("[email protected]") == "[email protected]"
assert email("[email protected]") == "[email protected]"
assert email("!#$%&'*+-/=?^_{|}~`@example.com") == "!#$%&'*+-/=?^_{|}~`@example.com"
def test_email_with_invalid_email():
try:
email("invalid_email")
except ValueError as e:
assert str(e) == "invalid_email is not a valid email."
try:
email("@example.com")
except ValueError as e:
assert str(e) == "@example.com is not a valid email."
try:
email("()@example.com")
except ValueError as e:
assert str(e) == "()@example.com is not a valid email."