Split backend tests into unit and integration suites, add isolated fixtures and coverage enforcement, and update CI and test documentation. Cover current authentication, content, notification, payment, media, and admin flows; fix behaviors revealed by the new tests. Validate both suites and the per-module gate against local PostgreSQL.
43 lines
1.1 KiB
Python
43 lines
1.1 KiB
Python
import pytest
|
|
|
|
from apps.users.email_identity import (
|
|
is_placeholder_email,
|
|
is_valid_mobile_number,
|
|
mask_mobile,
|
|
normalize_email_identity,
|
|
normalize_mobile_number,
|
|
)
|
|
|
|
|
|
pytestmark = pytest.mark.unit
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
("raw", "expected"),
|
|
[(None, None), (" ", None), (" Alice@EXAMPLE.COM ", "alice@example.com")],
|
|
)
|
|
def test_email_normalization(raw, expected):
|
|
assert normalize_email_identity(raw) == expected
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
("raw", "normalized", "valid"),
|
|
[
|
|
(None, None, False),
|
|
("+98 (0919) 000-0001", "9809190000001", False),
|
|
("0919-000-0001", "09190000001", True),
|
|
("123", "123", False),
|
|
],
|
|
)
|
|
def test_mobile_normalization_and_validation(raw, normalized, valid):
|
|
assert normalize_mobile_number(raw) == normalized
|
|
assert is_valid_mobile_number(raw) is valid
|
|
|
|
|
|
def test_masking_and_placeholder_identity():
|
|
assert mask_mobile(None) is None
|
|
assert mask_mobile("1234") == "1234"
|
|
assert mask_mobile("09190000001") == "09*****0001"
|
|
assert is_placeholder_email(" LEGACY@NOEMAIL.LOCAL ")
|
|
assert not is_placeholder_email("person@example.com")
|