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.
35 lines
1.3 KiB
Python
35 lines
1.3 KiB
Python
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)
|