示例#1
0
    def test_occurrence_timezone_mixed(self):
        '''mixed timezones should raise an error'''
        event = create_event()
        create_occurrence(event)
        eastern = timezone('US/Eastern')
        start_time = eastern.localize(datetime.datetime(2012, 9, 2, 0))
        end_time = datetime.datetime(2012, 9, 4, 0).replace(tzinfo=utc)

        self.assertRaises(TypeError, event.occurrences, (start_time, end_time))
    def test_set_occurrence_end_until(self):
        '''if there is an until in the rrule params set the
        occurrence_end to until
        '''
        until = datetime.datetime(2014, 9, 11).replace(tzinfo=utc)
        event = create_event()
        occurrence = create_occurrence(event, rrule_params={'until': until})

        self.assertEqual(occurrence.occurrence_end, until)
    def test_get_rrule_param_none(self):
        ''' rrule_param should return None if nothing is set '''

        event = create_event()
        params = None
        occurrence = create_occurrence(event, rrule_params=params)

        #occurrence = Occurrence.objects.get(pk=1)
        self.assertEqual(occurrence.rrule_params, None)
    def test_set_rrule_param(self):
        '''rrule_param should serialize the params and put them in
        the database
        '''
        event = create_event()
        params = {'count': 3}
        valid_json_string = '{"count": 3}'
        occurrence = create_occurrence(event, rrule_params=params)

        self.assertEqual(occurrence._rrule_params, valid_json_string)
    def test_get_rrule_param(self):
        '''rrule_param should return a python object identical
        to the params
        '''

        event = create_event()
        params = {'count': 3}
        occurrence = create_occurrence(event, rrule_params=params)

        self.assertEqual(occurrence.rrule_params, params)
示例#6
0
    def test_occurrence_timezone(self):
        '''occurrence should return occurrences in the same timezone'''
        event = create_event()
        create_occurrence(event)
        eastern = timezone('US/Eastern')
        start_time = eastern.localize(datetime.datetime(2012, 9, 2, 0))
        end_time = eastern.localize(datetime.datetime(2012, 9, 4, 0))

        occs = event.occurrences(start_time, end_time)

        for occ in occs:
            self.assertEqual(type(occ.tzinfo), type(eastern))
    def test_set_occurrence_end_count(self):
        '''if there is a count in the rrule params set the occurrence_end
        to the last one
        '''
        event = create_event()
        count = 7
        params = {'count': count}
        occurrence = create_occurrence(event, rrule_params=params,
                                       rrule_frequency='DAILY')

        # minus one day since we count the first one
        last = occurrence.start_time + datetime.timedelta(days=count - 1)

        self.assertEqual(occurrence.occurrence_end, last)
示例#8
0
    def setUp(self):
        # create user
        self.username = '******'
        self.password = '******'
        self.user = User.objects.create_user(self.username,
                                             '*****@*****.**', self.password)

        self.user.get_profile().timezone = "US/Eastern"
        self.user.get_profile().save()

        # create event and occurrance
        self.event = create_event()
        self.occurrence = create_occurrence(event=self.event, rrule_params="")

        # urls
        self.obj_url = '/api/v1/event/%s/' % self.event.pk
        self.list_url = '/api/v1/event/'

        # Client
        self.client = Client()
        self.client.login(username=self.username, password=self.password)