Example #1
0
    def testTimezonedWindowsWithDST(self):
        m = MaintenanceWindow('tester')
        m.dmd = self.dmd
        tzName = 'Europe/Kiev'
        tzInstance = tz.gettz(tzName)
        duration = 3 * 60

        def getLocalizedTimestamp(dateTime):
            localized_expected_time = dateTime.replace(tzinfo=tzInstance)
            return Time.awareDatetimeToTimestamp(localized_expected_time)

        FSOTM_Map = {
            # day before DST changing (Europe/Kiev) and first sunday of the month
            # Saturday      Sunday
            (2021, 3, 27):
            datetime(2021, 4, 4),
            (2021, 10, 30):
            datetime(2021, 11, 7),
        }

        for (yy, mm, dd), sunday in FSOTM_Map.items():
            startTime = getLocalizedTimestamp(datetime(yy, mm, dd, 12, 0))
            nowTime = getLocalizedTimestamp(datetime(yy, mm, dd, 15, 0))

            m.set(startTime, duration, m.DAILY, timezone=tzName)
            expected_timestamp = getLocalizedTimestamp(
                datetime(yy, mm, dd, 12, 0) + relativedelta(days=1))
            self.assertEqual(m.nextEvent(nowTime), expected_timestamp)

            m.set(startTime, duration, m.WEEKLY, timezone=tzName)
            expected_timestamp = getLocalizedTimestamp(
                datetime(yy, mm, dd, 12, 0) + relativedelta(days=7))
            self.assertEqual(m.nextEvent(nowTime), expected_timestamp)

            m.set(startTime, duration, m.EVERY_WEEKDAY, timezone=tzName)
            expected_timestamp = getLocalizedTimestamp(
                datetime(yy, mm, dd, 12, 0) + relativedelta(days=2))
            self.assertEqual(m.nextEvent(nowTime), expected_timestamp)

            m.set(startTime,
                  duration,
                  m.NTHWDAY,
                  'Sunday',
                  '1st',
                  timezone=tzName)
            expected_timestamp = getLocalizedTimestamp(sunday +
                                                       relativedelta(hours=12))
            self.assertEqual(m.nextEvent(nowTime), expected_timestamp)

            # DST: check that a mw takes the proper amount of time
            tt = getLocalizedTimestamp(datetime(yy, mm, dd, 0, 10, 9))
            m.set(tt, duration, m.DAILY, timezone=tzName)
            m.started = tt
            self.assertEqual(m.nextEvent(tt) - tt, duration * 60 - 1)
            m.started = None
    def testMaintenanceWindows(self):
        m = MaintenanceWindow('tester')
        m.dmd = self.dmd
        t = mktime((2006, 1, 29, 10, 45, 12, 6, 29, 0))
        P = 60 * 60 * 2
        # set(start, duration, repeat, enabled=True)
        m.set(t, P, m.NEVER)
        self.assert_(m.next() == None)
        m.set(t, P, m.DAILY)
        c = mktime((2006, 1, 30, 10, 45, 12, 6, 29, 0))
        self.assert_(m.next(t + P + 1) == c)
        m.set(t, P, m.WEEKLY)
        c = mktime((2006, 2, 5, 10, 45, 12, 6, 36, 0))
        self.assert_(m.next(t + 1) == c)
        m.set(t - DAY_SECONDS, P, m.EVERY_WEEKDAY)
        c = mktime((2006, 1, 30, 10, 45, 12, 7, 30, 0))
        self.assert_(m.next(t) == c)
        m.set(t, P, m.MONTHLY)
        c = mktime((2006, 2, 28, 10, 45, 12, 0, 0, 0))
        self.assert_(m.next(t + 1) == c)
        t2 = mktime((2005, 12, 31, 10, 45, 12, 0, 0, 0))
        m.set(t2, P, m.MONTHLY)
        c = mktime((2006, 1, 31, 10, 45, 12, 0, 0, 0))
        c2 = mktime((2006, 2, 28, 10, 45, 12, 0, 0, 0))
        self.assert_(m.next(t2 + 1) == c)
        self.assert_(m.next(c + 1) == c2)
        c = mktime((2006, 2, 5, 10, 45, 12, 0, 0, 0))
        m.set(t, P, m.NTHWDAY)
        self.assert_(m.next(t + 1) == c)
        c = mktime((2006, 1, 31, 10, 45, 12, 0, 0, 0))
        m.set(t, P, m.NTHWDAY, 'Tuesday', 'Last')
        self.assert_(m.next(t + 1) == c)
        c = mktime((2006, 2, 19, 10, 45, 12, 0, 0, 0))
        m.set(t, P, m.NTHWDAY, 'Sunday', '3rd')
        self.assert_(m.next(t + 1) == c)
        c = mktime((2006, 2, 22, 10, 45, 12, 0, 0, 0))
        m.set(t, P, m.NTHWDAY, 'Wednesday', 'Last')
        self.assert_(m.next(t + 1) == c)

        # DST
        FSOTM_Map = {
            # DST day      following first sunday of the month
            (2008, 3, 9): (2008, 4, 6),
            (2008, 11, 2): (2008, 12, 7),
        }
        for (yy, mm, dd), sunday in FSOTM_Map.items():
            duration = 3 * 60
            tt = mktime((yy, mm, dd, 12, 10, 9, 0, 0, -1))
            m.set(tt, duration, m.DAILY)
            c = mktime((yy, mm, dd + 1, 12, 10, 9, 0, 0, -1))
            self.assert_(m.next(tt + duration) == c)

            m.set(tt, duration, m.WEEKLY)
            c = mktime((yy, mm, dd + 7, 12, 10, 9, 0, 0, -1))
            self.assert_(m.next(tt + duration) == c)

            m.set(tt, duration, m.EVERY_WEEKDAY)
            c = mktime((yy, mm, dd + 1, 12, 10, 9, 0, 0, -1))
            self.assert_(m.next(tt + duration) == c)

            m.set(tt, duration, m.NTHWDAY)
            c = mktime(sunday + (12, 10, 9, 0, 0, -1))
            self.assert_(m.next(tt + duration) == c)

            # DST: check that a 3-hour range ends at the proper time
            tt = mktime((yy, mm, dd, 0, 10, 9, 0, 0, -1))
            m.set(tt, duration, m.DAILY)
            m.started = tt
            c = mktime((yy, mm, dd, 3, 10, 8, 0, 0, -1))
            self.assert_(m.nextEvent(tt) == c)
            m.started = None

        # skips
        m.skip = 2
        m.set(t, P, m.DAILY)
        c = mktime((2006, 1, 31, 10, 45, 12, 6, 29, 0))
        self.assert_(m.next(t + 1) == c)

        m.set(t, P, m.WEEKLY)
        c = mktime((2006, 2, 12, 10, 45, 12, 6, 36, 0))
        self.assert_(m.next(t + 1) == c)

        m.set(t, P, m.MONTHLY)
        c = mktime((2006, 3, 29, 9, 45, 12, 6, 36, 0))
        self.assert_(m.next(t + 1) == c)

        m.set(t - DAY_SECONDS * 2, P, m.EVERY_WEEKDAY)
        c = mktime((2006, 1, 31, 10, 45, 12, 7, 30, 0))
        self.assert_(m.next(t + 1) == c)

        c = mktime((2006, 3, 5, 10, 45, 12, 0, 0, 0))
        m.set(t, P, m.NTHWDAY)
        self.assert_(m.next(t + 1) == c)

        m1 = MaintenanceWindow('t1')
        m2 = MaintenanceWindow('t2')
        t = mktime((2006, 1, 29, 10, 45, 12, 6, 29, 0))
        duration = 1
        m1.set(t, duration, m.NEVER)
        m2.set(t + duration * 60, duration, m.NEVER)
        m1.started = t
        # ending of m1 should be < start of m2
        self.assert_(m1.nextEvent(t + 1) < m2.nextEvent(t + 1))

        #r = FakeRequest()
        r = None
        m.manage_editMaintenanceWindow(startDate='01/29/2006',
                                       startHours='10',
                                       startMinutes='45',
                                       durationDays='1',
                                       durationHours='1',
                                       durationMinutes='1',
                                       repeat='Weekly',
                                       startProductionState=state_Maintenance,
                                       enabled=True,
                                       REQUEST=r)

        #self.assert_('message' in r)
        #self.assert_(r['message'] == 'Saved Changes')
        self.assert_(m.start == t - 12)
        self.assert_(m.duration == 24 * 60 + 61)
        self.assert_(m.repeat == 'Weekly')
        self.assert_(m.startProductionState == state_Maintenance)
Example #3
0
    def testUTCMaintenanceWindows(self):
        m = MaintenanceWindow('tester')
        m.dmd = self.dmd
        tzInstance = tz.tzutc()

        def getLocalizedTimestamp(year, month, day, hour, minutes, seconds):
            localizedExpectedDateTime = datetime(year,
                                                 month,
                                                 day,
                                                 hour,
                                                 minutes,
                                                 seconds,
                                                 tzinfo=tzInstance)
            return Time.awareDatetimeToTimestamp(localizedExpectedDateTime)

        t = getLocalizedTimestamp(2006, 1, 29, 10, 45, 12)
        P = 60 * 60 * 2
        # set(start, duration, repeat, enabled=True)
        m.set(t, P, m.NEVER)
        self.assert_(m.next() == None)
        m.set(t, P, m.DAILY)
        c = getLocalizedTimestamp(2006, 1, 30, 10, 45, 12)
        self.assert_(m.next(t + P + 1) == c)
        m.set(t, P, m.WEEKLY)
        c = getLocalizedTimestamp(2006, 2, 5, 10, 45, 12)
        self.assert_(m.next(t + 1) == c)
        m.set(t - DAY_SECONDS, P, m.EVERY_WEEKDAY)
        c = getLocalizedTimestamp(2006, 1, 30, 10, 45, 12)
        self.assert_(m.next(t) == c)
        m.set(t, P, m.MONTHLY)
        c = getLocalizedTimestamp(2006, 2, 28, 10, 45, 12)
        self.assert_(m.next(t + 1) == c)
        t2 = getLocalizedTimestamp(2005, 12, 31, 10, 45, 12)
        m.set(t2, P, m.MONTHLY)
        c = getLocalizedTimestamp(2006, 1, 31, 10, 45, 12)
        c2 = getLocalizedTimestamp(2006, 2, 28, 10, 45, 12)
        self.assert_(m.next(t2 + 1) == c)
        self.assert_(m.next(c + 1) == c2)
        c = getLocalizedTimestamp(2006, 2, 5, 10, 45, 12)
        m.set(t, P, m.NTHWDAY)
        self.assert_(m.next(t + 1) == c)
        c = getLocalizedTimestamp(2006, 1, 31, 10, 45, 12)
        m.set(t, P, m.NTHWDAY, 'Tuesday', 'Last')
        self.assert_(m.next(t + 1) == c)
        c = getLocalizedTimestamp(2006, 2, 19, 10, 45, 12)
        m.set(t, P, m.NTHWDAY, 'Sunday', '3rd')
        self.assert_(m.next(t + 1) == c)
        c = getLocalizedTimestamp(2006, 2, 22, 10, 45, 12)
        m.set(t, P, m.NTHWDAY, 'Wednesday', 'Last')
        self.assert_(m.next(t + 1) == c)

        c = getLocalizedTimestamp(2006, 3, 13, 10, 45, 12)
        n = getLocalizedTimestamp(2006, 3, 6, 10, 45, 12)
        m.set(t, P, m.NTHWDAY, 'Monday', '2nd')
        self.assert_(m.next(n) == c)

        c = getLocalizedTimestamp(2006, 3, 29, 10, 45, 12)
        n = getLocalizedTimestamp(2006, 3, 6, 10, 45, 12)
        m.set(t, P, m.NTHWDAY, 'Wednesday', 'Last')
        self.assert_(m.next(n) == c)

        c = getLocalizedTimestamp(2007, 1, 8, 10, 45, 12)
        n = getLocalizedTimestamp(2007, 1, 2, 10, 45, 12)
        m.set(t, P, m.NTHWDAY, 'Monday', '2nd')
        self.assert_(m.next(n) == c)

        # DST
        FSOTM_Map = {
            # DST day      following first sunday of the month
            (2008, 3, 9):
            datetime(2008, 4, 6),
            (2008, 11, 2):
            datetime(2008, 12, 7),
        }
        for (yy, mm, dd), sunday in FSOTM_Map.items():
            duration = 3 * 60
            tt = getLocalizedTimestamp(yy, mm, dd, 12, 10, 9)
            m.set(tt, duration, m.DAILY)
            c = getLocalizedTimestamp(yy, mm, dd + 1, 12, 10, 9)
            self.assert_(m.next(tt + duration) == c)

            m.set(tt, duration, m.WEEKLY)
            c = getLocalizedTimestamp(yy, mm, dd + 7, 12, 10, 9)
            self.assert_(m.next(tt + duration) == c)

            m.set(tt, duration, m.EVERY_WEEKDAY)
            c = getLocalizedTimestamp(yy, mm, dd + 1, 12, 10, 9)
            self.assert_(m.next(tt + duration) == c)

            m.set(tt, duration, m.NTHWDAY)
            date = sunday + timedelta(hours=12, minutes=10, seconds=9)
            c = getLocalizedTimestamp(date.year, date.month, date.day,
                                      date.hour, date.minute, date.second)
            self.assert_(m.next(tt + duration) == c)

            # DST: check that a 3-hour range ends at the proper time
            tt = getLocalizedTimestamp(yy, mm, dd, 0, 10, 9)
            m.set(tt, duration, m.DAILY)
            m.started = tt
            c = getLocalizedTimestamp(yy, mm, dd, 3, 10, 8)
            self.assert_(m.nextEvent(tt) == c)
            m.started = None

        # skips
        m.skip = 2
        m.set(t, P, m.DAILY)
        c = getLocalizedTimestamp(2006, 1, 31, 10, 45, 12)
        self.assert_(m.next(t + 1) == c)

        m.set(t, P, m.WEEKLY)
        c = getLocalizedTimestamp(2006, 2, 12, 10, 45, 12)
        self.assert_(m.next(t + 1) == c)

        m.set(t, P, m.MONTHLY)
        c = getLocalizedTimestamp(2006, 3, 29, 10, 45, 12)
        self.assert_(m.next(t + 1) == c)

        m.set(t - DAY_SECONDS * 2, P, m.EVERY_WEEKDAY)
        c = getLocalizedTimestamp(2006, 1, 31, 10, 45, 12)
        self.assert_(m.next(t + 1) == c)

        c = getLocalizedTimestamp(2006, 3, 5, 10, 45, 12)
        m.set(t, P, m.NTHWDAY)
        self.assert_(m.next(t + 1) == c)

        m1 = MaintenanceWindow('t1')
        m2 = MaintenanceWindow('t2')
        t = getLocalizedTimestamp(2006, 1, 29, 10, 45, 12)
        duration = 1
        m1.set(t, duration, m.NEVER)
        m2.set(t + duration * 60, duration, m.NEVER)
        m1.started = t
        # ending of m1 should be < start of m2
        self.assert_(m1.nextEvent(t + 1) < m2.nextEvent(t + 1))

        #r = FakeRequest()
        r = None
        startDttm = 1138531500
        m.manage_editMaintenanceWindow(startDate='01/29/2006',
                                       startHours='10',
                                       startMinutes='45',
                                       startDateTime=str(startDttm),
                                       durationDays='1',
                                       durationHours='1',
                                       durationMinutes='1',
                                       repeat='Weekly',
                                       startProductionState=state_Maintenance,
                                       enabled=True,
                                       REQUEST=r)

        #self.assert_('message' in r)
        #self.assert_(r['message'] == 'Saved Changes')
        self.assertEqual(m.start, startDttm)
        self.assert_(m.duration == 24 * 60 + 61)
        self.assert_(m.repeat == 'Weekly')
        self.assert_(m.startProductionState == state_Maintenance)
Example #4
0
    def testTimezonedWindows(self):
        m = MaintenanceWindow('tester')
        m.dmd = self.dmd
        tzName = 'Europe/Kiev'
        tzInstance = tz.gettz(tzName)

        def getLocalizedTimestamp(year, month, day, hour, minutes):
            localizedExpectedDateTime = datetime(year,
                                                 month,
                                                 day,
                                                 hour,
                                                 minutes,
                                                 tzinfo=tzInstance)
            return Time.awareDatetimeToTimestamp(localizedExpectedDateTime)

        startTime = getLocalizedTimestamp(2021, 2, 19, 15, 0)
        duration = 60 * 60 * 2

        m.set(startTime, duration, m.NEVER, timezone=tzName)
        self.assertEqual(m.next(), None)

        m.set(startTime, duration, m.DAILY, timezone=tzName)
        expectedTimestamp = getLocalizedTimestamp(2021, 2, 20, 15, 0)
        self.assertEqual(m.next(startTime + duration + 1), expectedTimestamp)

        m.set(startTime, duration, m.WEEKLY, timezone=tzName)
        expectedTimestamp = getLocalizedTimestamp(2021, 2, 26, 15, 0)
        self.assertEqual(m.next(startTime + 1), expectedTimestamp)

        m.set(startTime, duration, m.EVERY_WEEKDAY)
        expectedTimestamp = getLocalizedTimestamp(2021, 2, 22, 15, 0)
        self.assertEqual(m.next(startTime), expectedTimestamp)

        m.set(startTime, duration, m.MONTHLY, timezone=tzName)
        expectedTimestamp = getLocalizedTimestamp(2021, 3, 19, 15, 0)
        self.assertEqual(m.next(startTime + 1), expectedTimestamp)

        t2 = getLocalizedTimestamp(2020, 12, 31, 15, 0)
        m.set(t2, duration, m.MONTHLY, timezone=tzName)
        expectedTimestamp_1 = getLocalizedTimestamp(2021, 1, 31, 15, 0)
        expectedTimestamp_2 = getLocalizedTimestamp(2021, 2, 28, 15, 0)
        self.assertEqual(m.next(t2 + 1), expectedTimestamp_1)
        self.assertEqual(m.next(expectedTimestamp_1 + 1), expectedTimestamp_2)

        expectedTimestamp = getLocalizedTimestamp(2021, 3, 7, 15, 0)
        m.set(startTime, duration, m.NTHWDAY, timezone=tzName)
        self.assertEqual(m.next(startTime + 1), expectedTimestamp)

        expectedTimestamp = getLocalizedTimestamp(2021, 2, 26, 15, 0)
        m.set(startTime,
              duration,
              m.NTHWDAY,
              'Friday',
              'Last',
              timezone=tzName)
        self.assertEqual(m.next(startTime + 1), expectedTimestamp)

        expectedTimestamp = getLocalizedTimestamp(2021, 2, 21, 15, 0)
        m.set(startTime, duration, m.NTHWDAY, 'Sunday', '3rd', timezone=tzName)
        self.assertEqual(m.next(startTime + 1), expectedTimestamp)

        expectedTimestamp = getLocalizedTimestamp(2021, 2, 24, 15, 0)
        m.set(startTime,
              duration,
              m.NTHWDAY,
              'Wednesday',
              'Last',
              timezone=tzName)
        self.assertEqual(m.next(startTime + 1), expectedTimestamp)

        expectedTimestamp = getLocalizedTimestamp(2021, 3, 19, 15, 0)
        m.set(startTime, duration, m.MONTHLY, timezone=tzName)
        self.assertEqual(m.next(startTime + 1), expectedTimestamp)

        nowTimestamp = getLocalizedTimestamp(2021, 3, 1, 15, 0)
        expectedTimestamp = getLocalizedTimestamp(2021, 3, 8, 15, 0)
        m.set(startTime, duration, m.NTHWDAY, 'Monday', '2nd', timezone=tzName)
        self.assertEqual(m.nextEvent(nowTimestamp), expectedTimestamp)

        nowTimestamp = getLocalizedTimestamp(2021, 3, 1, 15, 0)
        expectedTimestamp = getLocalizedTimestamp(2021, 3, 31, 15, 0)
        m.set(startTime,
              duration,
              m.NTHWDAY,
              'Wednesday',
              'Last',
              timezone=tzName)
        self.assertEqual(m.nextEvent(nowTimestamp), expectedTimestamp)

        nowTimestamp = getLocalizedTimestamp(2022, 3, 8, 15, 0)
        expectedTimestamp = getLocalizedTimestamp(2022, 3, 14, 15, 0)
        m.set(startTime, duration, m.NTHWDAY, 'Monday', '2nd', timezone=tzName)
        self.assertEqual(m.nextEvent(nowTimestamp), expectedTimestamp)

        # skips
        m.skip = 2
        m.set(startTime, duration, m.DAILY, timezone=tzName)
        expectedTimestamp = getLocalizedTimestamp(2021, 2, 21, 15, 0)
        self.assertEqual(m.next(startTime + 1), expectedTimestamp)
    def testMaintenanceWindows(self):
        m = MaintenanceWindow('tester')
        m.dmd = self.dmd
        t = mktime( (2006, 1, 29, 10, 45, 12, 6, 29, 0) )
        P = 60*60*2
        # set(start, duration, repeat, enabled=True)
        m.set(t, P, m.NEVER)
        self.assert_(m.next() == None)
        m.set(t, P, m.DAILY)
        c = mktime( (2006, 1, 30, 10, 45, 12, 6, 29, 0) )
        self.assert_(m.next(t + P + 1) == c)
        m.set(t, P, m.WEEKLY)
        c = mktime( (2006, 2, 5, 10, 45, 12, 6, 36, 0) )
        self.assert_(m.next(t + 1) == c)
        m.set(t - DAY_SECONDS, P, m.EVERY_WEEKDAY)
        c = mktime( (2006, 1, 30, 10, 45, 12, 7, 30, 0) )
        self.assert_(m.next(t) == c)
        m.set(t, P, m.MONTHLY)
        c = mktime( (2006, 2, 28, 10, 45, 12, 0, 0, 0) )
        self.assert_(m.next(t+1) == c)
        t2 = mktime( (2005, 12, 31, 10, 45, 12, 0, 0, 0) )
        m.set(t2, P, m.MONTHLY)
        c = mktime( (2006, 1, 31, 10, 45, 12, 0, 0, 0) )
        c2 = mktime( (2006, 2, 28, 10, 45, 12, 0, 0, 0) )
        self.assert_(m.next(t2+1) == c)
        self.assert_(m.next(c+1) == c2)
        c = mktime( (2006, 2, 5, 10, 45, 12, 0, 0, 0) )
        m.set(t, P, m.NTHWDAY)
        self.assert_(m.next(t+1) == c)
        c = mktime( (2006, 1, 31, 10, 45, 12, 0, 0, 0) )
        m.set(t, P, m.NTHWDAY, 'Tuesday', 'Last')
        self.assert_(m.next(t+1) == c)
        c = mktime( (2006, 2, 19, 10, 45, 12, 0, 0, 0) )
        m.set(t, P, m.NTHWDAY, 'Sunday', '3rd')
        self.assert_(m.next(t+1) == c)
        c = mktime( (2006, 2, 22, 10, 45, 12, 0, 0, 0) )
        m.set(t, P, m.NTHWDAY, 'Wednesday', 'Last')
        self.assert_(m.next(t+1) == c)


        # DST
        FSOTM_Map = {
            # DST day      following first sunday of the month
            (2008, 3, 9):  (2008, 4, 6),
            (2008, 11, 2): (2008, 12, 7),
            }
        for (yy, mm, dd), sunday in FSOTM_Map.items():
            duration = 3*60
            tt = mktime( (yy, mm, dd, 12, 10, 9, 0, 0, -1) )
            m.set(tt, duration, m.DAILY)
            c = mktime( (yy, mm, dd + 1, 12, 10, 9, 0, 0, -1) )
            self.assert_(m.next(tt + duration) == c)

            m.set(tt, duration, m.WEEKLY)
            c = mktime( (yy, mm, dd + 7, 12, 10, 9, 0, 0, -1) )
            self.assert_(m.next(tt + duration) == c)

            m.set(tt, duration, m.EVERY_WEEKDAY)
            c = mktime( (yy, mm, dd + 1, 12, 10, 9, 0, 0, -1) )
            self.assert_(m.next(tt + duration) == c)

            m.set(tt, duration, m.NTHWDAY)
            c = mktime( sunday + (12, 10, 9, 0, 0, -1) )
            self.assert_(m.next(tt + duration) == c)

            # DST: check that a 3-hour range ends at the proper time
            tt = mktime( (yy, mm, dd, 0, 10, 9, 0, 0, -1) )
            m.set(tt, duration, m.DAILY)
            m.started = tt
            c = mktime( (yy, mm, dd, 3, 10, 8, 0, 0, -1) )
            self.assert_(m.nextEvent(tt) == c)
            m.started = None

        # skips
        m.skip = 2
        m.set(t, P, m.DAILY)
        c = mktime( (2006, 1, 31, 10, 45, 12, 6, 29, 0) )
        self.assert_(m.next(t + 1) == c)

        m.set(t, P, m.WEEKLY)
        c = mktime( (2006, 2, 12, 10, 45, 12, 6, 36, 0) )
        self.assert_(m.next(t + 1) == c)

        m.set(t, P, m.MONTHLY)
        c = mktime( (2006, 3, 29, 9, 45, 12, 6, 36, 0) )
        self.assert_(m.next(t + 1) == c)

        m.set(t - DAY_SECONDS * 2, P, m.EVERY_WEEKDAY)
        c = mktime( (2006, 1, 31, 10, 45, 12, 7, 30, 0) )
        self.assert_(m.next(t + 1) == c)

        c = mktime( (2006, 3, 5, 10, 45, 12, 0, 0, 0) )
        m.set(t, P, m.NTHWDAY)
        self.assert_(m.next(t+1) == c)

        m1 = MaintenanceWindow('t1')
        m2 = MaintenanceWindow('t2')
        t = mktime( (2006, 1, 29, 10, 45, 12, 6, 29, 0) )
        duration = 1
        m1.set(t, duration, m.NEVER)
        m2.set(t + duration * 60, duration, m.NEVER)
        m1.started = t
        # ending of m1 should be < start of m2
        self.assert_(m1.nextEvent(t + 1) < m2.nextEvent(t + 1))

        #r = FakeRequest()
        r = None
        m.manage_editMaintenanceWindow(
                                         startDate='01/29/2006',
                                         startHours='10',
                                         startMinutes='45',
                                         durationDays='1',
                                         durationHours='1',
                                         durationMinutes='1',
                                         repeat='Weekly',
                                         startProductionState=state_Maintenance,
                                         enabled=True,
                                         REQUEST=r)

        #self.assert_('message' in r)
        #self.assert_(r['message'] == 'Saved Changes')
        self.assert_(m.start == t - 12)
        self.assert_(m.duration == 24*60+61)
        self.assert_(m.repeat == 'Weekly')
        self.assert_(m.startProductionState == state_Maintenance)