Esempio n. 1
0
 def test_sleep_between_checks(self, RruleThread):
     func = Mock()
     rr = Mock()
     rr.between.return_value = False
     thread = RruleThread(func, rr, sleep_between_checks=0.0010)
     thread.start()
     sleep(0.005)
     assert func.call_count == 0
     assert rr.between.call_count > 1
Esempio n. 2
0
 def test_sleep_between_checks(self, RruleThread):
     func = Mock()
     rr = Mock()
     rr.between.return_value = False
     thread = RruleThread(func, rr, sleep_between_checks=0.0010)
     thread.start()
     sleep(0.005)
     assert func.call_count == 0
     assert rr.between.call_count > 1
Esempio n. 3
0
 def test_last_execution(self, RruleThread):
     func = Mock()
     thread = RruleThread(func, rrule.rrule(
         rrule.MONTHLY,
         bymonthday=1,
         dtstart=datetime(2014, 10, 30, 13, 21, 18)))
     thread.last_execution = datetime(2014, 10, 30, 13, 21, 18)
     thread.start()
     sleep(0.005)
     assert func.call_count == 1
Esempio n. 4
0
 def test_last_execution(self, RruleThread):
     func = Mock()
     thread = RruleThread(func, rrule.rrule(
         rrule.MONTHLY,
         bymonthday=1,
         dtstart=datetime(2014, 10, 30, 13, 21, 18)))
     thread.last_execution = datetime(2014, 10, 30, 13, 21, 18)
     thread.start()
     sleep(0.005)
     assert func.call_count == 1
Esempio n. 5
0
    def test_func_raises(self, RruleThread):
        func = Mock(__name__='buggy')
        func.side_effect = KeyError
        thread = RruleThread(func, rrule.rrule(
            rrule.MONTHLY,
            bymonthday=1,
            dtstart=datetime(2014, 10, 30, 13, 21, 18)))
        thread.last_execution = datetime(2014, 10, 30, 13, 21, 18)

        with patch('palladium.util.logger') as logger:
            thread.start()
            sleep(0.005)
            assert func.call_count == 1
            assert logger.exception.call_count == 1
Esempio n. 6
0
    def test_func_raises(self, RruleThread):
        func = Mock(__name__='buggy')
        func.side_effect = KeyError
        thread = RruleThread(func, rrule.rrule(
            rrule.MONTHLY,
            bymonthday=1,
            dtstart=datetime(2014, 10, 30, 13, 21, 18)))
        thread.last_execution = datetime(2014, 10, 30, 13, 21, 18)

        with patch('palladium.util.logger') as logger:
            thread.start()
            sleep(0.005)
            assert func.call_count == 1
            assert logger.exception.call_count == 1
Esempio n. 7
0
    def test_rrule_from_dict(self, RruleThread):
        func = Mock()
        now = datetime.now()
        rrule_info = {
            'freq': 'DAILY',
            'dtstart': '2014-10-30T13:21:18',
            }
        expected = rrule.rrule(
            rrule.DAILY, dtstart=datetime(2014, 10, 30, 13, 21, 18))

        thread = RruleThread(func, rrule_info)
        assert thread.rrule.after(now) == expected.after(now)