Example #1
0
    def test_getPeriodsForDay_otherTZ(self):
        from schooltool.timetable.browser.cal import DailyTimetableCalendarRowsView

        view = DailyTimetableCalendarRowsView(None, TestRequest())
        # Auckland is 12h ahead of London
        view.getPersonTimezone = lambda: timezone('Pacific/Auckland')
        uk = timezone('Europe/London')

        delta = timedelta(minutes=115)
        td = timedelta
        ukdt = lambda *args: uk.localize(datetime(*args))
        self.assertEquals(view.getPeriodsForDay(date(2004, 10, 14)),
                          [('B', ukdt(2004, 10, 13, 12, 0), td(minutes=55)),
                           ('C', ukdt(2004, 10, 13, 13, 0), delta),
                           ('D', ukdt(2004, 10, 13, 15, 0), delta),
                           ('A', ukdt(2004, 10, 14, 9, 0), delta),
                           ('B', ukdt(2004, 10, 14, 11, 0), td(minutes=60))])

        # However, if there is no time period, we return []
        self.assertEquals(view.getPeriodsForDay(date(2005, 10, 14)),
                          [])

        # If there is no timetable schema, we return []
        ITimetableSchemaContainer(self.app).default_id = None
        self.assertEquals(view.getPeriodsForDay(date(2004, 10, 14)),
                          [])
Example #2
0
    def test_getPeriodsForLastDayOfTerm(self):
        from schooltool.timetable.browser.cal import DailyTimetableCalendarRowsView

        view = DailyTimetableCalendarRowsView(None, TestRequest())
        # We need the start date and the end date different
        view.getPersonTimezone = lambda: timezone('America/Chicago')
        self.assertEquals(view.getPeriodsForDay(date(2005, 6, 1)), [])
Example #3
0
    def test_getPeriodsForLastDayOfTerm(self):
        from schooltool.timetable.browser.cal import DailyTimetableCalendarRowsView

        view = DailyTimetableCalendarRowsView(None, TestRequest())
        # We need the start date and the end date different
        view.getPersonTimezone = lambda: timezone('America/Chicago')
        self.assertEquals(view.getPeriodsForDay(date(2005, 6, 1)), [])
Example #4
0
    def test_getPeriodsForDay_sameTZ(self):
        from schooltool.timetable.browser.cal import DailyTimetableCalendarRowsView

        view = DailyTimetableCalendarRowsView(None, TestRequest())
        uk = timezone('Europe/London')
        view.getPersonTimezone = lambda: uk
        delta = timedelta(minutes=115)
        ukdt = lambda *args: uk.localize(datetime(*args))
        self.assertEquals(view.getPeriodsForDay(date(2004, 10, 14)),
                          [('A', ukdt(2004, 10, 14, 9, 0), delta),
                           ('B', ukdt(2004, 10, 14, 11, 0), delta),
                           ('C', ukdt(2004, 10, 14, 13, 0), delta),
                           ('D', ukdt(2004, 10, 14, 15, 0), delta)])

        # However, if there is no time period, we return []
        self.assertEquals(view.getPeriodsForDay(date(2005, 10, 14)), [])

        # If there is no timetable schema, we return []
        ITimetableSchemaContainer(self.app).default_id = None
        self.assertEquals(view.getPeriodsForDay(date(2004, 10, 14)), [])
Example #5
0
    def test_getPeriodsForDayBetweenTerms(self):
        from schooltool.term.term import Term
        term3 = Term('Sample', date(2005, 6, 2), date(2005, 8, 1))
        ITermContainer(self.app)['2005-autumn'] = term3
        term3.schooldays = [('A', time(9, 0), timedelta(minutes=115))]
        self.term2.schooldays = [('B', time(10, 0), timedelta(minutes=115))]

        from schooltool.timetable.browser.cal import DailyTimetableCalendarRowsView

        view = DailyTimetableCalendarRowsView(None, TestRequest())
        # We need the start date and the end date different
        view.getPersonTimezone = lambda: timezone('America/Chicago')
        self.assertEquals(len(view.getPeriodsForDay(date(2005, 6, 1))), 1)
Example #6
0
    def test_getPeriodsForDayBetweenTerms(self):
        from schooltool.term.term import Term
        term3 = Term('Sample', date(2005, 6, 2), date(2005, 8, 1))
        ITermContainer(self.app)['2005-autumn'] = term3
        term3.schooldays = [('A', time(9,0), timedelta(minutes=115))]
        self.term2.schooldays = [('B', time(10,0), timedelta(minutes=115))]

        from schooltool.timetable.browser.cal import DailyTimetableCalendarRowsView

        view = DailyTimetableCalendarRowsView(None, TestRequest())
        # We need the start date and the end date different
        view.getPersonTimezone = lambda: timezone('America/Chicago')
        self.assertEquals(len(view.getPeriodsForDay(date(2005, 6, 1))), 1)
Example #7
0
    def test_getPeriods(self):
        from schooltool.timetable.browser.cal import DailyTimetableCalendarRowsView

        request = TestRequest()
        view = DailyTimetableCalendarRowsView(ISchoolToolCalendar(self.person), request)

        # if no user has logged we should get an empty list
        self.assertEquals(view.getPeriods(date(2005, 1, 1)), [])

        # same if our user doesn't want to see periods in his calendar
        request.setPrincipal(self.person)
        IPersonPreferences(self.person).cal_periods = False
        self.assertEquals(view.getPeriods(date(2005, 1, 1)), [])

        # if currently logged in user wants to see periods, the
        # parameter is passed to getPeriodsForDay method.
        view.getPeriodsForDay = lambda cursor: ("Yep", cursor)
        IPersonPreferences(self.person).cal_periods = True
        self.assertEquals(view.getPeriods(date(2005, 1, 1)),
                          ("Yep", date(2005, 1, 1)))
Example #8
0
    def test_getPeriods(self):
        from schooltool.timetable.browser.cal import DailyTimetableCalendarRowsView

        request = TestRequest()
        view = DailyTimetableCalendarRowsView(ISchoolToolCalendar(self.person),
                                              request)

        # if no user has logged we should get an empty list
        self.assertEquals(view.getPeriods(date(2005, 1, 1)), [])

        # same if our user doesn't want to see periods in his calendar
        request.setPrincipal(self.person)
        IPersonPreferences(self.person).cal_periods = False
        self.assertEquals(view.getPeriods(date(2005, 1, 1)), [])

        # if currently logged in user wants to see periods, the
        # parameter is passed to getPeriodsForDay method.
        view.getPeriodsForDay = lambda cursor: ("Yep", cursor)
        IPersonPreferences(self.person).cal_periods = True
        self.assertEquals(view.getPeriods(date(2005, 1, 1)),
                          ("Yep", date(2005, 1, 1)))