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