Exemple #1
0
    def test_date_changed(self):
        event = EventFactory(
            title='Test Title',
            status='open',
            location=GeolocationFactory.create(position=Point(20.0, 10.0)),
            start=now() + timedelta(days=4),
        )

        ParticipantFactory.create_batch(3, activity=event, status='new')
        ParticipantFactory.create(activity=event, status='withdrawn')

        mail.outbox = []

        event.start = event.start + timedelta(days=1)
        event.save()

        recipients = [message.to[0] for message in mail.outbox]

        self.assertTrue(
            event.local_timezone_name in mail.outbox[0].body
        )

        self.assertTrue(
            formats.time_format(event.local_start) in mail.outbox[0].body
        )

        for participant in event.contributions.instance_of(Participant):
            if participant.status == 'new':
                self.assertTrue(participant.user.email in recipients)
            else:
                self.assertFalse(participant.user.email in recipients)
Exemple #2
0
    def test_date_not_changed(self):
        event = EventFactory(
            title='Test Title',
            status='open',
            start=now() + timedelta(days=4),
        )
        ParticipantFactory.create_batch(3, activity=event, status='new')
        ParticipantFactory.create(activity=event, status='withdrawn')

        mail.outbox = []

        event.title = 'New title'
        event.save()

        self.assertEqual(len(mail.outbox), 0)
Exemple #3
0
    def test_date_changed_passed(self):
        event = EventFactory(
            title='Test Title',
            status='open',
            start=now() - timedelta(days=4),
        )

        ParticipantFactory.create_batch(3, activity=event, status='new')
        ParticipantFactory.create(activity=event, status='withdrawn')

        mail.outbox = []

        event.start = event.start + timedelta(days=1)
        event.save()

        recipients = [message.to[0] for message in mail.outbox]

        for participant in event.contributions.instance_of(Participant):
            self.assertFalse(participant.user.email in recipients)