Beispiel #1
0
    def test_new_event_simple(self):
        from swingtime.forms import EventForm, MultipleOccurrenceForm

        data = dict(
            title='QWERTY',
            event_type='1',
            day='2008-12-11',
            start_time_delta='28800',
            end_time_delta='29700',
            year_month_ordinal_day='2',
            month_ordinal_day='2',
            holidays='skip',
            year_month_ordinal='1',
            month_option='each',
            repeats='count',
            freq='2',
            occurences='2',
            month_ordinal='1',
            request={'user': '******'},
        )

        evt_form = EventForm(data)
        occ_form = MultipleOccurrenceForm(data)
        self.assertTrue(evt_form.is_valid(), evt_form.errors.as_text())
        self.assertTrue(occ_form.is_valid(), occ_form.errors.as_text())

        self.assertEqual(occ_form.cleaned_data['start_time'],
                         datetime(2008, 12, 11, 8),
                         'Bad start_time: %s' % pformat(occ_form.cleaned_data))
Beispiel #2
0
    def test_new_event_simple(self):
        data = dict(title='QWERTY',
                    event_type='1',
                    day='2008-12-11',
                    start_time_delta='28800',
                    end_time_delta='29700',
                    year_month_ordinal_day='2',
                    month_ordinal_day='2',
                    year_month_ordinal='1',
                    month_option='each',
                    count=2,
                    repeats='count',
                    freq='2',
                    month_ordinal='1')

        evt_form = EventForm(data)
        occ_form = MultipleOccurrenceForm(data)
        self.assertTrue(evt_form.is_valid(), evt_form.errors.as_text())
        self.assertTrue(occ_form.is_valid(), occ_form.errors.as_text())

        evt = occ_form.save(evt_form.save())
        self.assertEqual(evt.occurrence_set.count(), 2)

        self.assertEqual(
            occ_form.cleaned_data['start_time'], datetime(2008, 12, 11, 8),
            'Bad start_time: {0}'.format(pformat(occ_form.cleaned_data)))
Beispiel #3
0
    def test_freq(self):
        et = EventType.objects.get(pk=1)
        e = Event.objects.create(title='FIRE BAD!',
                                 description='***',
                                 event_type=et)
        dtstart = datetime(2015, 2, 12)
        data = dict(day=dtstart.date(),
                    freq=rrule.MONTHLY,
                    month_option='on',
                    month_ordinal=1,
                    month_ordinal_day=5,
                    repeats='until',
                    start_time_delta='28800',
                    end_time_delta='29700',
                    until=datetime(2015, 6, 10))
        mof = MultipleOccurrenceForm(data, initial={'dtstart': dtstart})
        self.assertTrue(mof.is_valid(), mof.errors.as_text())

        mof.save(e)
        expected = [
            date(2015, m, d) for m, d in ((3, 6), (4, 3), (5, 1), (6, 5))
        ]
        actual = [o.start_time.date() for o in e.occurrence_set.all()]
        self.assertEqual(
            expected,
            actual, '\nGOT:\n{}\n^\nEXP:\n{}'.format(pformat(actual),
                                                     pformat(expected)))
Beispiel #4
0
    def test_new_event_simple(self, play_type):
        data = dict(
            title='QWERTY',
            event_type=play_type.id,
            day='2008-12-11',
            start_time_delta='28800',
            end_time_delta='29700',
            year_month_ordinal_day='2',
            month_ordinal_day='2',
            year_month_ordinal='1',
            month_option='each',
            count=2,
            repeats='count',
            freq='2',
            month_ordinal='1'
        )
        
        evt_form = EventForm(data)
        occ_form = MultipleOccurrenceForm(data)
        assert True == evt_form.is_valid()
        assert '' == evt_form.errors.as_text()
        assert True == occ_form.is_valid()
        assert '' == occ_form.errors.as_text()

        evt = occ_form.save(evt_form.save())
        assert evt.occurrence_set.count() == 2
        assert occ_form.cleaned_data['start_time'] == datetime(2008, 12, 11, 8)
Beispiel #5
0
    def test_new_event_simple(self):
        data = dict(
            title='QWERTY',
            event_type='1',
            day='2008-12-11',
            start_time_delta='28800',
            end_time_delta='29700',
            year_month_ordinal_day='2',
            month_ordinal_day='2',
            year_month_ordinal='1',
            month_option='each',
            count=2,
            repeats='count',
            freq='2',
            month_ordinal='1'
        )
        
        evt_form = EventForm(data)
        occ_form = MultipleOccurrenceForm(data)
        self.assertTrue(evt_form.is_valid(), evt_form.errors.as_text())
        self.assertTrue(occ_form.is_valid(), occ_form.errors.as_text())

        evt = occ_form.save(evt_form.save())
        self.assertEqual(evt.occurrence_set.count(), 2)
        
        self.assertEqual(
            occ_form.cleaned_data['start_time'],
            datetime(2008, 12, 11, 8),
            'Bad start_time: {0}'.format(pformat(occ_form.cleaned_data))
        )
Beispiel #6
0
    def test_new_event_simple(self):
        from swingtime.forms import EventForm, MultipleOccurrenceForm

        data = dict(
            title='QWERTY',
            event_type='1',
            day='2008-12-11',
            start_time_delta='28800',
            end_time_delta='29700',
            year_month_ordinal_day='2',
            month_ordinal_day='2',
            holidays='skip',
            year_month_ordinal='1',
            month_option='each',
            repeats='count',
            freq='2',
            occurences='2',
            month_ordinal='1',
            request={'user': '******'},
        )

        evt_form = EventForm(data)
        occ_form = MultipleOccurrenceForm(data)
        self.assertTrue(evt_form.is_valid(), evt_form.errors.as_text())
        self.assertTrue(occ_form.is_valid(), occ_form.errors.as_text())

        self.assertEqual(
            occ_form.cleaned_data['start_time'],
            datetime(2008, 12, 11, 8),
            'Bad start_time: %s' % pformat(occ_form.cleaned_data)
        )
    def test_new_event_simple(self, play_type):
        data = dict(
            title='QWERTY',
            event_type=play_type.id,
            day='2008-12-11',
            start_time_delta='28800',
            end_time_delta='29700',
            year_month_ordinal_day='2',
            month_ordinal_day='2',
            year_month_ordinal='1',
            month_option='each',
            count=2,
            repeats='count',
            freq='2',
            month_ordinal='1'
        )
        
        evt_form = EventForm(data)
        occ_form = MultipleOccurrenceForm(data)
        assert True == evt_form.is_valid()
        assert '' == evt_form.errors.as_text()
        assert True == occ_form.is_valid()
        assert '' == occ_form.errors.as_text()

        evt = occ_form.save(evt_form.save())
        assert evt.occurrence_set.count() == 2
        assert occ_form.cleaned_data['start_time'] == datetime(2008, 12, 11, 8)
Beispiel #8
0
    def test_yearly(self, play_type):
        e = Event.objects.create(title='YEARLY',
                                 description='YYYY',
                                 event_type=play_type)
        dtstart = datetime(2018, 3, 18)
        data = dict(
            day=dtstart.date(),
            freq=rrule.YEARLY,
            year_months=['3'],
            repeats='count',
            count='3',
            month_option='each',
            start_time_delta='54000',
            end_time_delta='57600',
            is_year_month_ordinal='on',
            year_month_ordinal='3',
            year_month_ordinal_day='7',
        )
        mof = MultipleOccurrenceForm(data, initial={'dtstart': dtstart})
        assert True == mof.is_valid()

        mof.save(e)
        expected = [date(2018, 3, 18), date(2019, 3, 17), date(2020, 3, 15)]
        actual = [o.start_time.date() for o in e.occurrence_set.all()]
        assert expected == actual
Beispiel #9
0
    def test_freq(self, play_type):
        e = Event.objects.create(title='FIRE BAD!', description='***', event_type=play_type)
        dtstart = datetime(2015,2,12)
        data = dict(
            day=dtstart.date(),
            freq=rrule.MONTHLY,
            month_option='on',
            month_ordinal=1,
            month_ordinal_day=5,
            repeats='until',
            start_time_delta='28800',
            end_time_delta='29700',
            until=datetime(2015, 6, 10)
        )
        mof = MultipleOccurrenceForm(data, initial={'dtstart': dtstart})
        assert True == mof.is_valid()

        mof.save(e)
        expected = [date(2015,m,d) for m,d in ((3, 6), (4, 3), (5, 1), (6, 5))]
        actual = [o.start_time.date() for o in e.occurrence_set.all()]
        assert expected == actual
    def test_freq(self, play_type):
        e = Event.objects.create(title='FIRE BAD!', description='***', event_type=play_type)
        dtstart = datetime(2015,2,12)
        data = dict(
            day=dtstart.date(),
            freq=rrule.MONTHLY,
            month_option='on',
            month_ordinal=1,
            month_ordinal_day=5,
            repeats='until',
            start_time_delta='28800',
            end_time_delta='29700',
            until=datetime(2015, 6, 10)
        )
        mof = MultipleOccurrenceForm(data, initial={'dtstart': dtstart})
        assert True == mof.is_valid()

        mof.save(e)
        expected = [date(2015,m,d) for m,d in ((3, 6), (4, 3), (5, 1), (6, 5))]
        actual = [o.start_time.date() for o in e.occurrence_set.all()]
        assert expected == actual
Beispiel #11
0
    def test_freq(self):
        et = EventType.objects.get(pk=1)
        e = Event.objects.create(title='FIRE BAD!', description='***', event_type=et)
        dtstart = datetime(2015,2,12)
        data = dict(
            day=dtstart.date(),
            freq=rrule.MONTHLY,
            month_option='on',
            month_ordinal=1,
            month_ordinal_day=5,
            repeats='until',
            start_time_delta='28800',
            end_time_delta='29700',
            until=datetime(2015, 6, 10)
        )
        mof = MultipleOccurrenceForm(data, initial={'dtstart': dtstart})
        self.assertTrue(mof.is_valid(), mof.errors.as_text())

        mof.save(e)
        expected = [date(2015,m,d) for m,d in ((3, 6), (4, 3), (5, 1), (6, 5))]
        actual = [o.start_time.date() for o in e.occurrence_set.all()]
        self.assertEqual(expected, actual, '\nGOT:\n{}\n^\nEXP:\n{}'.format(pformat(actual), pformat(expected)))
    def test_yearly(self, play_type):
        e = Event.objects.create(title='YEARLY', description='YYYY', event_type=play_type)
        dtstart = datetime(2018,3,18)
        data = dict(
            day=dtstart.date(),
            freq=rrule.YEARLY,
            year_months=['3'],
            repeats='count',
            count='3',
            month_option='each',
            start_time_delta='54000',
            end_time_delta='57600',
            is_year_month_ordinal = 'on',
            year_month_ordinal = '3',
            year_month_ordinal_day = '7',
        )
        mof = MultipleOccurrenceForm(data, initial={'dtstart': dtstart})
        assert True == mof.is_valid()

        mof.save(e)
        expected = [date(2018,3,18), date(2019,3,17), date(2020,3,15)]
        actual = [o.start_time.date() for o in e.occurrence_set.all()]
        assert expected == actual