Пример #1
0
    def setUpClass(cls):
        super(TestActionExecutionService, cls).setUpClass()
        cls.runner = RunnerTypeAPI(**RUNNER)
        cls.runnerdb = RunnerType.add_or_update(
            RunnerTypeAPI.to_model(cls.runner))

        runner_api = RunnerTypeAPI(**RUNNER_ACTION_CHAIN)
        RunnerType.add_or_update(RunnerTypeAPI.to_model(runner_api))

        cls.actions = {
            ACTION['name']:
            ActionAPI(**ACTION),
            ACTION_WORKFLOW['name']:
            ActionAPI(**ACTION_WORKFLOW),
            ACTION_OVR_PARAM['name']:
            ActionAPI(**ACTION_OVR_PARAM),
            ACTION_OVR_PARAM_MUTABLE['name']:
            ActionAPI(**ACTION_OVR_PARAM_MUTABLE),
            ACTION_OVR_PARAM_IMMUTABLE['name']:
            ActionAPI(**ACTION_OVR_PARAM_IMMUTABLE),
            ACTION_OVR_PARAM_BAD_ATTR['name']:
            ActionAPI(**ACTION_OVR_PARAM_BAD_ATTR),
            ACTION_OVR_PARAM_BAD_ATTR_NOOP['name']:
            ActionAPI(**ACTION_OVR_PARAM_BAD_ATTR_NOOP)
        }

        cls.actiondbs = {
            name: Action.add_or_update(ActionAPI.to_model(action))
            for name, action in six.iteritems(cls.actions)
        }

        cls.container = RunnerContainer()
 def setUpClass(cls):
     super(TestActionExecutionService, cls).setUpClass()
     cls.runner = RunnerTypeAPI(**RUNNER)
     cls.runnerdb = RunnerType.add_or_update(RunnerTypeAPI.to_model(cls.runner))
     cls.action = ActionAPI(**ACTION)
     cls.actiondb = Action.add_or_update(ActionAPI.to_model(cls.action))
     cls.container = RunnerContainer()
Пример #3
0
    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
Пример #4
0
 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.')
Пример #5
0
    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
Пример #6
0
 def __init__(self, connection):
     self.connection = connection
     self.container = RunnerContainer()
     self._dispatcher = BufferedDispatcher()
Пример #7
0
 def __init__(self, connection, queues):
     super(ActionExecutionDispatcher, self).__init__(connection, queues)
     self.container = RunnerContainer()
     self._running_liveactions = set()
Пример #8
0
 def __init__(self, connection, queues):
     super(ActionExecutionDispatcher, self).__init__(connection, queues)
     self.container = RunnerContainer()
Пример #9
0
 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.')