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.
24 lines
958 B
Python
24 lines
958 B
Python
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
|