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.
19 lines
564 B
Python
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()
|