def test__worker_run_once_assertion_error_assert(self): runner = SearchRunner({}) runner.sla_action = 'assert' runner.worker_helper = mock.Mock(side_effect=y_exc.SLAValidationError) with self.assertRaises(y_exc.SLAValidationError): runner._worker_run_once('sequence 1')
def test__worker_run_once(self): def update(*args): args[-1].update(data) data = { 'key1': { 'inner1': 'value1', 'done': 0, }, 'key2': { 'done': None, }, } runner = SearchRunner({}) runner.worker_helper = mock.Mock(side_effect=update) self.assertFalse(runner._worker_run_once('sequence 1'))
def test__worker_run_once_non_assertion_error(self): runner = SearchRunner({}) runner.sla_action = 'monitor' runner.worker_helper = mock.Mock(side_effect=RuntimeError) self.assertFalse(runner._worker_run_once('sequence 1'))
def test__worker_run_once_non_assertion_error_none(self): runner = SearchRunner({}) runner.worker_helper = mock.Mock(side_effect=RuntimeError) self.assertTrue(runner._worker_run_once('sequence 1'))