Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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