def test_should_callback_when_queue_is_empty_and_errors_occurred_equals_errors_allowed(self, fake_reactor, _): pool = DeferredPool('pool-name', queue=[], nr_errors_tolerated=5) pool.error_count = 5 pool._finish() fake_reactor.callLater.assert_called_with(0, pool.callback)
def test_should_callback_when_queue_is_empty_and_no_errors_occurred( self, fake_reactor, _): pool = DeferredPool('pool-name', queue=[]) pool._finish() fake_reactor.callLater.assert_called_with(0, pool.callback)
def test_should_errback_when_error_count_is_too_high(self, fake_reactor, _, action_exception, __): pool = DeferredPool('pool-name', queue=['some-task'], nr_errors_tolerated=4) pool.error_count = 5 pool._finish() fake_reactor.callLater.assert_called_with(0, pool.errback, action_exception.return_value) action_exception.assert_called_with('stops: error count too high, 5 > 4', 1)
def test_should_callback_when_queue_is_empty_and_less_errors_than_allowed_occurred( self, fake_reactor, _): pool = DeferredPool('pool-name', queue=[], nr_errors_tolerated=6) pool.error_count = 5 pool._finish() fake_reactor.callLater.assert_called_with(0, pool.callback)
def test_should_errback_when_actions_could_not_be_executed(self, fake_reactor, _, action_exception, __): task = lambda: None task.action = lambda: None task.action.dump = lambda: 'do something' pool = DeferredPool('pool-name', queue=[task]) pool._finish() fake_reactor.callLater.assert_called_with(0, pool.errback, action_exception.return_value) action_exception.assert_called_with('Could not execute 1 action(s)', 1)
def test_should_errback_when_actions_could_not_be_executed( self, fake_reactor, _, action_exception, __): task = lambda: None task.action = lambda: None task.action.dump = lambda: 'do something' pool = DeferredPool('pool-name', queue=[task]) pool._finish() fake_reactor.callLater.assert_called_with( 0, pool.errback, action_exception.return_value) action_exception.assert_called_with('Could not execute 1 action(s)', 1)
def test_should_errback_when_error_count_is_too_high( self, fake_reactor, _, action_exception, __): pool = DeferredPool('pool-name', queue=['some-task'], nr_errors_tolerated=4) pool.error_count = 5 pool._finish() fake_reactor.callLater.assert_called_with( 0, pool.errback, action_exception.return_value) action_exception.assert_called_with( 'stops: error count too high, 5 > 4', 1)
def test_should_callback_when_queue_is_empty_and_no_errors_occurred(self, fake_reactor, _): pool = DeferredPool('pool-name', queue=[]) pool._finish() fake_reactor.callLater.assert_called_with(0, pool.callback)