def setUp(self): # event that only occurs once self.event = EventFactory(rule=None) # event that occurs for one week daily with one custom occurrence self.event_daily = EventFactory() self.occurrence = OccurrenceFactory(event=self.event, title='foo_occurrence')
def setUp(self): self.not_found_event = EventFactory( set__start=-24, set__end=-24, set__creation_date=-24, rule=None) self.event = EventFactory() self.occurrence = OccurrenceFactory( event=self.event, title='foo_occurrence') self.single_time_event = EventFactory(rule=None)
def test_delete_period(self): """Test for the ``delete_period`` function.""" occurrence = OccurrenceFactory() occurrence.delete_period('all') self.assertEqual(Occurrence.objects.all().count(), 0, msg=('Should delete only the first occurrence.')) event = EventFactory(set__start=0, set__end=0) occurrence = OccurrenceFactory(event=event, set__start=0, set__end=0) occurrence.delete_period('this one') self.assertEqual(Occurrence.objects.all().count(), 0, msg=('Should delete only the first occurrence.')) event = EventFactory(set__start=0, set__end=0) occurrence = OccurrenceFactory(event=event, set__start=0, set__end=0) occurrence.delete_period('following') self.assertEqual(Event.objects.all().count(), 0, msg=('Should delete the event and the occurrence.')) occurrence_1 = OccurrenceFactory() occurrence_2 = OccurrenceFactory(event=occurrence_1.event) period = occurrence_2.event.end_recurring_period occurrence_2.delete_period('this one') self.assertGreater(period, occurrence_2.event.end_recurring_period, msg=('Should shorten event period, if last' ' occurencce is deleted.')) occurrence_2 = OccurrenceFactory(event=occurrence_1.event) occurrence_3 = OccurrenceFactory(event=occurrence_1.event) period = occurrence_2.event.end_recurring_period occurrence_2.delete_period('this one') self.assertTrue(Occurrence.objects.get(pk=occurrence_2.pk).cancelled, msg=('Should set the occurrence to cancelled.')) period = occurrence_3.event.end_recurring_period occurrence_3.delete_period('following') self.assertEqual( Occurrence.objects.all().count(), 0, msg=('Should delete all occurrences with this start date.'))
def test_delete_period(self): """Test for the ``delete_period`` function.""" occurrence = OccurrenceFactory() occurrence.delete_period('all') self.assertEqual(Occurrence.objects.all().count(), 0, msg=( 'Should delete only the first occurrence.')) event = EventFactory(set__start=0, set__end=0) occurrence = OccurrenceFactory(event=event, set__start=0, set__end=0) occurrence.delete_period('this one') self.assertEqual(Occurrence.objects.all().count(), 0, msg=( 'Should delete only the first occurrence.')) event = EventFactory(set__start=0, set__end=0) occurrence = OccurrenceFactory(event=event, set__start=0, set__end=0) occurrence.delete_period('following') self.assertEqual(Event.objects.all().count(), 0, msg=( 'Should delete the event and the occurrence.')) occurrence_1 = OccurrenceFactory() occurrence_2 = OccurrenceFactory(event=occurrence_1.event) period = occurrence_2.event.end_recurring_period occurrence_2.delete_period('this one') self.assertGreater(period, occurrence_2.event.end_recurring_period, msg=('Should shorten event period, if last' ' occurencce is deleted.')) occurrence_2 = OccurrenceFactory(event=occurrence_1.event) occurrence_3 = OccurrenceFactory(event=occurrence_1.event) period = occurrence_2.event.end_recurring_period occurrence_2.delete_period('this one') self.assertTrue(Occurrence.objects.get(pk=occurrence_2.pk).cancelled, msg=('Should set the occurrence to cancelled.')) period = occurrence_3.event.end_recurring_period occurrence_3.delete_period('following') self.assertEqual(Occurrence.objects.all().count(), 0, msg=( 'Should delete all occurrences with this start date.'))