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:
2026-09-26 16:50:29 +03:30
parent 3ec28638d1
commit ff99130938
76 changed files with 3271 additions and 1357 deletions

View File

@@ -0,0 +1,34 @@
from types import SimpleNamespace
import pytest
from django.contrib import admin
from apps.events.admin import EventAdmin
from apps.events.models import Event
pytestmark = pytest.mark.unit
def test_event_admin_formats_empty_price_and_capacity():
model_admin = EventAdmin(Event, admin.site)
event = SimpleNamespace(price=None, capacity=None, current_attendees_count=3, is_registration_open=True)
assert model_admin.price_display(event) == "رایگان"
assert model_admin.capacity_display(event) == "نامحدود"
assert model_admin.attendees_display(event) == 3
assert model_admin.is_registration_open_display(event)
def test_event_admin_status_actions_update_selection(mocker):
model_admin = EventAdmin(Event, admin.site)
mocker.patch.object(model_admin, "message_user")
queryset = mocker.Mock()
queryset.count.return_value = 2
for action, status in (
(model_admin.make_published, Event.StatusChoices.PUBLISHED),
(model_admin.make_draft, Event.StatusChoices.DRAFT),
(model_admin.make_cancelled, Event.StatusChoices.CANCELLED),
(model_admin.make_completed, Event.StatusChoices.COMPLETED),
):
action(SimpleNamespace(), queryset)
queryset.update.assert_called_with(status=status)