Esempio n. 1
0
    def test_monthly(self):
        cfg = parse_daily('1st day')
        sch = scheduler.GeneralScheduler(**cfg._asdict())
        next_run_date = sch.next_run_time(None)

        assert_gt(next_run_date, self.now)
        assert_equal(next_run_date.month, 7)
Esempio n. 2
0
 def test_wildcards(self):
     cfg = parse_daily('every day')
     assert_equal(cfg.ordinals, None)
     assert_equal(cfg.monthdays, None)
     assert_equal(cfg.weekdays, None)
     assert_equal(cfg.months, None)
     assert_equal(cfg.timestr, '00:00')
Esempio n. 3
0
 def test_parse_no_month(self):
     cfg = parse_daily('1st,2nd,3rd,10th day at 00:00')
     assert_equal(cfg.ordinals, None)
     assert_equal(cfg.monthdays, set((1,2,3,10)))
     assert_equal(cfg.weekdays, None)
     assert_equal(cfg.months, None)
     assert_equal(cfg.timestr, '00:00')
Esempio n. 4
0
 def test_parse_no_weekday(self):
     cfg = parse_daily('1st,2nd,3rd,10th day of march,apr,September at 00:00')
     assert_equal(cfg.ordinals, None)
     assert_equal(cfg.monthdays, set((1,2,3,10)))
     assert_equal(cfg.weekdays, None)
     assert_equal(cfg.months, set((3, 4, 9)))
     assert_equal(cfg.timestr, '00:00')
Esempio n. 5
0
 def test_parse_monthly(self):
     for test_str in ('1st day', '1st day of month'):
         cfg = parse_daily(test_str)
         assert_equal(cfg.ordinals, None)
         assert_equal(cfg.monthdays, set([1]))
         assert_equal(cfg.weekdays, None)
         assert_equal(cfg.months, None)
         assert_equal(cfg.timestr, '00:00')
Esempio n. 6
0
    def test_weekly(self):
        cfg = parse_daily('every monday at 01:00')
        sch = scheduler.GeneralScheduler(**cfg._asdict())
        next_run_date = sch.next_run_time(None)

        assert_gte(next_run_date, self.now)
        assert_equal(calendar.weekday(next_run_date.year,
                                      next_run_date.month,
                                      next_run_date.day), 0)
Esempio n. 7
0
    def test_daily(self):
        cfg = parse_daily('every day')
        sch = scheduler.GeneralScheduler(**cfg._asdict())
        next_run_date = sch.next_run_time(None)

        assert_gte(next_run_date, self.now)
        assert_equal(next_run_date.month, 6)
        assert_equal(next_run_date.day, 2)
        assert_equal(next_run_date.hour, 0)
Esempio n. 8
0
 def test_parse_all(self):
     cfg = parse_daily('1st,2nd,3rd,4th monday,Tue of march,apr,September at 00:00')
     assert_equal(cfg.ordinals, set((1, 2, 3, 4)))
     assert_equal(cfg.monthdays, None)
     assert_equal(cfg.weekdays, set((1, 2)))
     assert_equal(cfg.months, set((3, 4, 9)))
     assert_equal(cfg.timestr, '00:00')
     assert_equal(scheduler.GeneralScheduler(**cfg._asdict()),
                  scheduler.GeneralScheduler(**cfg._asdict()))
Esempio n. 9
0
    def test_daily_with_time(self):
        cfg = parse_daily('every day at 02:00')
        sch = scheduler.GeneralScheduler(**cfg._asdict())
        next_run_date = sch.next_run_time(None)

        assert_gte(next_run_date, self.now)
        assert_equal(next_run_date.year, self.now.year)
        assert_equal(next_run_date.month, 6)
        assert_equal(next_run_date.day, 1)
        assert_equal(next_run_date.hour, 2)
        assert_equal(next_run_date.minute, 0)
Esempio n. 10
0
    def test_weekly_in_month(self):
        cfg = parse_daily('every monday of january at 00:01')
        sch = scheduler.GeneralScheduler(**cfg._asdict())
        next_run_date = sch.next_run_time(None)

        assert_gte(next_run_date, self.now)
        assert_equal(next_run_date.year, self.now.year+1)
        assert_equal(next_run_date.month, 1)
        assert_equal(next_run_date.hour, 0)
        assert_equal(next_run_date.minute, 1)
        assert_equal(calendar.weekday(next_run_date.year,
                                      next_run_date.month,
                                      next_run_date.day), 0)