Files
guilan-ace-backend/apps/users/tests/unit/test_signals.py
Amirhossein Khalili ff99130938 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.
2026-09-26 16:50:29 +03:30

19 lines
564 B
Python

from types import SimpleNamespace
import pytest
from apps.users.signals import ensure_username_on_registration
pytestmark = pytest.mark.unit
def test_missing_username_is_generated_only_for_new_account(mocker):
user = SimpleNamespace(username="", save=mocker.Mock())
ensure_username_on_registration(None, user, created=True)
assert len(user.username) == 10
user.save.assert_called_once_with(update_fields=["username"])
user.save.reset_mock()
ensure_username_on_registration(None, user, created=False)
user.save.assert_not_called()