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:
23
core/tests/integration/test_soft_delete.py
Normal file
23
core/tests/integration/test_soft_delete.py
Normal file
@@ -0,0 +1,23 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user