def test_delete_period(self):
        occurrence = mixer.blend('calendarium.Occurrence')
        occurrence.delete_period('all')
        self.assertEqual(Occurrence.objects.all().count(), 0, msg=(
            'Should delete only the first occurrence.'))

        event = mixer.blend(
            'calendarium.Event', start=now() - timedelta(hours=0),
            end=now() - timedelta(hours=0))
        occurrence = mixer.blend(
            'calendarium.Occurrence', event=event,
            start=now() - timedelta(hours=0), end=now() - timedelta(hours=0))
        occurrence.delete_period('this one')
        self.assertEqual(Occurrence.objects.all().count(), 0, msg=(
            'Should delete only the first occurrence.'))

        event = mixer.blend(
            'calendarium.Event', start=now() - timedelta(hours=0),
            end=now() - timedelta(hours=0))
        event.save()
        occurrence = mixer.blend(
            'calendarium.Occurrence', event=event,
            start=now() - timedelta(hours=0), end=now() - timedelta(hours=0))
        occurrence.delete_period('following')
        self.assertEqual(Event.objects.all().count(), 0, msg=(
            'Should delete the event and the occurrence.'))

        occurrence_1 = mixer.blend(
            'calendarium.Occurrence', start=now(),
            end=now() + timedelta(days=1),
            original_start=now() + timedelta(hours=1))
        occurrence_2 = mixer.blend(
            'calendarium.Occurrence', start=now(),
            end=now() + timedelta(days=1),
            original_start=now() + timedelta(hours=1))
        occurrence_2.event = occurrence_1.event
        occurrence_2.save()
        occurrence_2.delete_period('this one')
        # Result is equal instead of greater. Needs to be fixed.
        # self.assertGreater(period, occurrence_2.event.end_recurring_period,
        #                    msg=('Should shorten event period, if last'
        #                         ' occurencce is deleted.'))

        occurrence_3 = mixer.blend(
            'calendarium.Occurrence', start=now(),
            end=now() + timedelta(days=1),
            original_start=now() + timedelta(hours=1))
        occurrence_3.event = occurrence_1.event
        occurrence_3.save()
        occurrence_4 = mixer.blend(
            'calendarium.Occurrence', start=now(),
            end=now() + timedelta(days=1),
            original_start=now() + timedelta(hours=1))
        occurrence_4.event = occurrence_1.event
        occurrence_4.save()
        occurrence_3.delete_period('this one')
        occurrence_1.delete_period('following')
        self.assertEqual(Occurrence.objects.all().count(), 0, msg=(
            'Should delete all occurrences with this start date.'))
Pickling support.
dataset/ETHPy150Open bitmazk/django-calendarium/calendarium/tests/models_tests.py/OccurrenceTestCase.test_delete_period--crossover with--dataset/ETHPy150Open CollabQ/CollabQ/vendor/django/db/models/sql/query.py/BaseQuery.__getstate__