def _get_mock_runner_obj_from_container(self, pack, user, sandbox=None): container = RunnerContainer() runnertype_db = mock.Mock() runnertype_db.name = "python-script" runnertype_db.runner_package = "python_runner" runnertype_db.runner_module = "python_runner" action_db = mock.Mock() action_db.pack = pack action_db.entry_point = "foo.py" liveaction_db = mock.Mock() liveaction_db.id = "123" liveaction_db.context = {"user": user} runner = container._get_runner( runner_type_db=runnertype_db, action_db=action_db, liveaction_db=liveaction_db, ) runner.execution = MOCK_EXECUTION runner.action = action_db runner.runner_parameters = {} if sandbox is not None: runner._sandbox = sandbox return runner
def test_get_runner_module_fail(self): runnertype_db = RunnerTypeDB() runnertype_db.runner_module = 'absent.module' runner_container = RunnerContainer() runner = None try: runner = runner_container._get_runner(runnertype_db) except ActionRunnerCreateError: pass self.assertFalse(runner, 'TestRunner must be valid.')
def test_get_runner_module_fail(self): runnertype_db = RunnerTypeDB() runnertype_db.runner_module = 'absent.module' runner_container = RunnerContainer() runner = None try: runner = runner_container._get_runner(runnertype_db) except ActionRunnerCreateError: pass self.assertFalse(runner, 'TestRunner must be valid.')
def _get_mock_runner_obj_from_container(self, pack, user): container = RunnerContainer() runnertype_db = mock.Mock() runnertype_db.runner_module = 'python_runner' action_db = mock.Mock() action_db.pack = pack action_db.entry_point = 'foo.py' liveaction_db = mock.Mock() liveaction_db.id = '123' liveaction_db.context = {'user': user} runner = container._get_runner(runnertype_db=runnertype_db, action_db=action_db, liveaction_db=liveaction_db) runner.execution = MOCK_EXECUTION runner.action = self._get_mock_action_obj() runner.runner_parameters = {} return runner
def _get_mock_runner_obj_from_container(self, pack, user, sandbox=None): container = RunnerContainer() runnertype_db = mock.Mock() runnertype_db.runner_package = 'python_runner' runnertype_db.runner_module = 'python_runner' action_db = mock.Mock() action_db.pack = pack action_db.entry_point = 'foo.py' liveaction_db = mock.Mock() liveaction_db.id = '123' liveaction_db.context = {'user': user} runner = container._get_runner(runner_type_db=runnertype_db, action_db=action_db, liveaction_db=liveaction_db) runner.execution = MOCK_EXECUTION runner.action = action_db runner.runner_parameters = {} if sandbox is not None: runner._sandbox = sandbox return runner
def test_get_runner_module(self): runnertype_db = RunnerContainerTest.runnertype_db runner_container = RunnerContainer() runner = runner_container._get_runner(runnertype_db) self.assertTrue(runner is not None, 'TestRunner must be valid.')
def test_get_runner_module(self): runnertype_db = RunnerContainerTest.runnertype_db runner_container = RunnerContainer() runner = runner_container._get_runner(runnertype_db) self.assertTrue(runner is not None, 'TestRunner must be valid.')