Beispiel #1
0
    def test_creator_notification_is_not_sent_when_not_priced(self, mock_notification):
        """Test that email is not sent when event is not priced"""

        self.event.payment_due_date = timezone.now() - timedelta(days=2)
        self.event.is_priced = False
        self.event.save()

        notify_event_creator_when_payment_overdue.delay()
        mock_notification.assert_not_called()
Beispiel #2
0
    def test_creator_notification_is_not_sent_past_end_time(self, mock_notification):
        """Test that email is not sent when event is past end time"""

        self.event.payment_due_date = timezone.now() - timedelta(days=2)
        self.event.end_time = timezone.now() - timedelta(hours=1)
        self.event.save()

        notify_event_creator_when_payment_overdue.delay()
        mock_notification.assert_not_called()
Beispiel #3
0
    def test_creator_notification_is_not_sent_when_everyone_has_paid(self, mock_notification):
        """Test that email is not sent when event is past due and everyone has paid"""

        self.event.payment_due_date = timezone.now() - timedelta(days=2)
        self.event.save()
        self.registration.set_payment_success()

        notify_event_creator_when_payment_overdue.delay()
        mock_notification.assert_not_called()
Beispiel #4
0
    def test_creator_notification_when_event_is_past_due_date(self, mock_notification):
        """Test that email is sent when event is past due and user has not paid"""

        self.event.payment_due_date = timezone.now() - timedelta(days=2)
        self.event.save()
        notify_event_creator_when_payment_overdue.delay()
        call = mock_notification.mock_calls[0]
        self.assertEqual(call[1], (self.event.created_by, ))
        self.assertEqual(call[2]['event'], self.event)
        self.assertEqual(1, len(call[2]['users']))
        mock_notification.assert_called_once()
Beispiel #5
0
    def test_creator_notification_when_past_due_date_and_charge_failed(self, mock_notification):
        """Test that email is sent when event is past due and user has a failed charge"""

        self.event.payment_due_date = timezone.now() - timedelta(days=2)
        self.event.save()
        self.registration.charge_id = 'CHARGE_ID'
        self.registration.charge_status = constants.PAYMENT_FAILURE
        notify_event_creator_when_payment_overdue.delay()
        call = mock_notification.mock_calls[0]
        self.assertEqual(call[1], (self.event.created_by, ))
        self.assertEqual(call[2]['event'], self.event)
        self.assertEqual(1, len(call[2]['users']))
        mock_notification.assert_called_once()
Beispiel #6
0
    def test_creator_notification_when_event_is_past_due_date_multiple(self, mock_notification):
        """Test that email is sent when event is past due and multiple users has not paid"""

        self.event.payment_due_date = timezone.now() - timedelta(days=2)
        self.event.save()

        user = get_dummy_users(1)[0]
        AbakusGroup.objects.get(name='Abakus').add_user(user)

        registration_two = Registration.objects.get_or_create(event=self.event, user=user)[0]
        self.event.register(registration_two)

        notify_event_creator_when_payment_overdue.delay()
        call = mock_notification.mock_calls[0]
        self.assertEqual(call[1], (self.event.created_by, ))
        self.assertEqual(call[2]['event'], self.event)
        self.assertEqual(2, len(call[2]['users']))
        mock_notification.assert_called_once()
Beispiel #7
0
    def test_creator_notification_only_shows_those_who_have_not_paid(self, mock_notification):
        """Test creator notify only list those who has not paid for an overdue event"""

        self.event.payment_due_date = timezone.now() - timedelta(days=2)
        self.event.save()

        user = get_dummy_users(1)[0]
        AbakusGroup.objects.get(name='Abakus').add_user(user)

        registration_two = Registration.objects.get_or_create(event=self.event, user=user)[0]
        self.event.register(registration_two)
        registration_two.set_payment_success()

        notify_event_creator_when_payment_overdue.delay()
        call = mock_notification.mock_calls[0]
        self.assertEqual(call[1], (self.event.created_by, ))
        self.assertEqual(call[2]['event'], self.event)
        self.assertEqual(1, len(call[2]['users']))
        mock_notification.assert_called_once()