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
apps/communications/tests/integration/test_reminders.py
Normal file
23
apps/communications/tests/integration/test_reminders.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from datetime import timedelta
|
||||
|
||||
import pytest
|
||||
from django.utils import timezone
|
||||
|
||||
from apps.communications.tasks import send_event_reminders
|
||||
from apps.events.models import Registration
|
||||
|
||||
|
||||
pytestmark = [pytest.mark.integration, pytest.mark.django_db]
|
||||
|
||||
|
||||
def test_reminder_targets_confirmed_attendees_only(event_factory, user_factory, mocker):
|
||||
notify = mocker.patch("apps.communications.tasks.notify_user")
|
||||
now = timezone.now()
|
||||
event = event_factory(start_time=now + timedelta(hours=24), end_time=now + timedelta(hours=26))
|
||||
confirmed = user_factory()
|
||||
pending = user_factory()
|
||||
Registration.objects.create(event=event, user=confirmed, status=Registration.StatusChoices.CONFIRMED)
|
||||
Registration.objects.create(event=event, user=pending, status=Registration.StatusChoices.PENDING)
|
||||
assert send_event_reminders.run() == "Event reminders sent to 1 users"
|
||||
notify.assert_called_once()
|
||||
assert notify.call_args.args[0] == confirmed.id
|
||||
Reference in New Issue
Block a user