示例#1
0
    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')
示例#2
0
    def test__worker_run(self):
        scenario_cfg = {
            'runner': {
                'interval': 0,
                'timeout': 1
            },
        }

        runner = SearchRunner({})
        runner._worker_run_once = mock.Mock(side_effect=[0, 0, 1])

        runner._worker_run(mock.Mock(), 'my_method', scenario_cfg, {})
示例#3
0
    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'))
示例#4
0
    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'))
示例#5
0
    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'))