Files
guilan-ace-backend/core/tests/integration/test_soft_delete.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

24 lines
794 B
Python

import pytest
from apps.events.models import Event
pytestmark = [pytest.mark.integration, pytest.mark.django_db]
def test_soft_delete_hides_record_and_restore_reveals_it(event_factory):
event = event_factory()
event.delete()
assert not Event.objects.filter(pk=event.pk).exists()
assert Event.deleted_objects.filter(pk=event.pk).exists()
assert Event.all_objects.get_queryset().dead().filter(pk=event.pk).exists()
assert not Event.all_objects.get_queryset().alive().filter(pk=event.pk).exists()
event.restore()
assert Event.objects.filter(pk=event.pk).exists()
def test_hard_delete_removes_row(event_factory):
event = event_factory()
Event.all_objects.filter(pk=event.pk).hard_delete()
assert not Event.all_objects.filter(pk=event.pk).exists()