2024-09-12 18:09:16 +08:00
|
|
|
import pytest
|
|
|
|
|
2024-06-17 22:32:59 +09:00
|
|
|
from libs.helper import email
|
|
|
|
|
|
|
|
|
|
|
|
def test_email_with_valid_email():
|
|
|
|
assert email("test@example.com") == "test@example.com"
|
|
|
|
assert email("TEST12345@example.com") == "TEST12345@example.com"
|
|
|
|
assert email("test+test@example.com") == "test+test@example.com"
|
|
|
|
assert email("!#$%&'*+-/=?^_{|}~`@example.com") == "!#$%&'*+-/=?^_{|}~`@example.com"
|
|
|
|
|
|
|
|
|
|
|
|
def test_email_with_invalid_email():
|
2024-09-12 18:09:16 +08:00
|
|
|
with pytest.raises(ValueError, match="invalid_email is not a valid email."):
|
2024-06-17 22:32:59 +09:00
|
|
|
email("invalid_email")
|
|
|
|
|
2024-09-12 18:09:16 +08:00
|
|
|
with pytest.raises(ValueError, match="@example.com is not a valid email."):
|
2024-06-17 22:32:59 +09:00
|
|
|
email("@example.com")
|
|
|
|
|
2024-09-12 18:09:16 +08:00
|
|
|
with pytest.raises(ValueError, match="()@example.com is not a valid email."):
|
2024-06-17 22:32:59 +09:00
|
|
|
email("()@example.com")
|