예제 #1
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
예제 #2
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
예제 #3
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
예제 #4
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