Пример #1
0
 def test_months(self):
     now = datetime.datetime.now()
     timing = self.all_stars.copy()
     timing['months'] = [now.month]
     self.assert_(libcron.time_to_run(now, timing))
     
     now += datetime.timedelta(days=31)
     self.assertNotEqual(now.month, timing['months'][0])
     self.assertFalse(libcron.time_to_run(now, timing))
Пример #2
0
 def test_minutes(self):
     now = datetime.datetime.now()
     timing = self.all_stars.copy()
     timing['minutes'] = [now.minute]
     self.assert_(libcron.time_to_run(now, timing))
     
     now += datetime.timedelta(seconds=60)
     self.assertNotEqual(now.minute, timing['minutes'][0])
     self.assertFalse(libcron.time_to_run(now, timing))
Пример #3
0
 def test_hours(self):
     now = datetime.datetime.now()
     timing = self.all_stars.copy()
     timing['hours'] = [now.hour]
     self.assert_(libcron.time_to_run(now, timing))
     
     now += datetime.timedelta(minutes=60)
     self.assertNotEqual(now.hour, timing['hours'][0])
     self.assertFalse(libcron.time_to_run(now, timing))
Пример #4
0
    def test_days_and_dow(self):
        # test all stars and day match
        now = datetime.datetime.now()
        timing = self.all_stars.copy()
        timing['days'] = [now.day]
        self.assert_(libcron.time_to_run(now, timing))
        
        # test all stars and dow match
        timing['days'] = self.all_stars['days']
        timing['dow'] = [now.isoweekday()]
        self.assert_(libcron.time_to_run(now, timing))
        
        # even if day doesn't match, if dow does, it should run
        tomorrow = datetime.datetime.now() + datetime.timedelta(days=1)
        timing['days'] = [tomorrow.day]
        self.assert_(libcron.time_to_run(now, timing))
        
        # even if dow doesn't match, if day does, it should run
        tomorrow = datetime.datetime.now() + datetime.timedelta(days=1)
        timing['dow'] = [tomorrow.isoweekday()]
        timing['days'] = [now.day]
        self.assert_(libcron.time_to_run(now, timing))
        
        # if only one of he two is restricted and it doesn't match, it should
        # not run
        timing['days'] = [tomorrow.day]
        timing['dow'] = self.all_stars['dow']
        self.assertFalse(libcron.time_to_run(now, timing))
        timing['days'] = self.all_stars['days']
        timing['dow'] = [tomorrow.isoweekday()]
        self.assertFalse(libcron.time_to_run(now, timing))
        
        # also make sure 0 == 7 for dow
        now = datetime.datetime(2009, 9, 6, 12, 0, 0)
        timing = self.all_stars.copy()
        timing['dow'] = [0]
        self.assertEqual(now.isoweekday(), 7)
        self.assert_(libcron.time_to_run(now, timing))
        
        

        
Пример #5
0
 def test_allstars(self):
     now = datetime.datetime.now()
     self.assert_(libcron.time_to_run(now, self.all_stars))