test: migrate backend suites to pytest with module coverage gate
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.
This commit is contained in:
25
apps/users/tests/integration/test_user_models.py
Normal file
25
apps/users/tests/integration/test_user_models.py
Normal file
@@ -0,0 +1,25 @@
|
||||
import pytest
|
||||
from apps.users.models import User
|
||||
from apps.users.resources import UserResource
|
||||
|
||||
@pytest.mark.django_db
|
||||
@pytest.mark.integration
|
||||
class TestUserIdentityTests:
|
||||
|
||||
def test_email_is_optional_and_flags_follow_identity(self):
|
||||
user = User.objects.create_user(username='mobile_only', mobile='09191110000', password='password')
|
||||
assert user.email is None
|
||||
assert not user.is_email_verified
|
||||
user.email = ' PERSON@EXAMPLE.COM '
|
||||
user.save(update_fields=['email'])
|
||||
user.refresh_from_db()
|
||||
assert user.email == 'person@example.com'
|
||||
assert user.is_email_verified
|
||||
user.email = None
|
||||
user.save(update_fields=['email'])
|
||||
user.refresh_from_db()
|
||||
assert not user.is_email_verified
|
||||
|
||||
def test_display_name_prefers_mobile_when_email_absent(self):
|
||||
user = User.objects.create_user(username='mobile_only', mobile='09191110001', password='password')
|
||||
assert user.mobile in str(user)
|
||||
Reference in New Issue
Block a user