Ejemplo n.º 1
0
 def test_get_runner_module_fail(self):
     runnertype_db = RunnerTypeDB()
     runnertype_db.runner_module = 'absent.module'
     runner = None
     try:
         runner = get_runner(runnertype_db.runner_module)
     except ActionRunnerCreateError:
         pass
     self.assertFalse(runner, 'TestRunner must be valid.')
Ejemplo n.º 2
0
 def test_get_runner_module_fail(self):
     runnertype_db = RunnerTypeDB()
     runnertype_db.runner_module = 'absent.module'
     runner = None
     try:
         runner = get_runner(runnertype_db.runner_module)
     except ActionRunnerCreateError:
         pass
     self.assertFalse(runner, 'TestRunner must be valid.')
Ejemplo n.º 3
0
 def _create_save_runnertype(metadata=False):
     created = RunnerTypeDB(name='python')
     created.description = ''
     created.enabled = True
     if not metadata:
         created.runner_parameters = {'r1': None, 'r2': None}
     else:
         created.runner_parameters = {
             'r1': {'type': 'object', 'properties': {'r1a': {'type': 'string'}}},
             'r2': {'type': 'string', 'required': True}
         }
     created.runner_module = 'nomodule'
     return RunnerType.add_or_update(created)
Ejemplo n.º 4
0
 def _create_save_runnertype(metadata=False):
     created = RunnerTypeDB(name='python')
     created.description = ''
     created.enabled = True
     if not metadata:
         created.runner_parameters = {'r1': None, 'r2': None}
     else:
         created.runner_parameters = {
             'r1': {'type': 'object', 'properties': {'r1a': {'type': 'string'}}},
             'r2': {'type': 'string', 'required': True}
         }
     created.runner_module = 'nomodule'
     return RunnerType.add_or_update(created)
Ejemplo n.º 5
0
 def _create_save_runnertype(metadata=False):
     created = RunnerTypeDB(name="python")
     created.description = ""
     created.enabled = True
     if not metadata:
         created.runner_parameters = {"r1": None, "r2": None}
     else:
         created.runner_parameters = {
             "r1": {"type": "object", "properties": {"r1a": {"type": "string"}}},
             "r2": {"type": "string", "required": True},
         }
     created.runner_module = "nomodule"
     return RunnerType.add_or_update(created)
Ejemplo n.º 6
0
 def _create_save_runnertype(metadata=False):
     created = RunnerTypeDB(name="python")
     created.description = ""
     created.enabled = True
     if not metadata:
         created.runner_parameters = {"r1": None, "r2": None}
     else:
         created.runner_parameters = {
             "r1": {
                 "type": "object",
                 "properties": {
                     "r1a": {
                         "type": "string"
                     }
                 }
             },
             "r2": {
                 "type": "string",
                 "required": True
             },
         }
     created.runner_module = "nomodule"
     return RunnerType.add_or_update(created)
Ejemplo n.º 7
0
# limitations under the License.

import jsonschema
import mock
import yaml

import st2actions.bootstrap.actionsregistrar as actions_registrar
from st2common.persistence.action import Action
import st2common.validators.api.action as action_validator
from st2common.models.db.runner import RunnerTypeDB
import st2tests.base as tests_base
import st2tests.fixturesloader as fixtures_loader

MOCK_RUNNER_TYPE_DB = RunnerTypeDB()
MOCK_RUNNER_TYPE_DB.name = 'run-local'
MOCK_RUNNER_TYPE_DB.runner_module = 'st2.runners.local'


class ActionsRegistrarTest(tests_base.DbTestCase):
    @mock.patch.object(action_validator, '_is_valid_pack', mock.MagicMock(return_value=True))
    @mock.patch.object(action_validator, '_get_runner_model',
                       mock.MagicMock(return_value=MOCK_RUNNER_TYPE_DB))
    def test_register_all_actions(self):
        try:
            packs_base_path = fixtures_loader.get_fixtures_base_path()
            all_actions_in_db = Action.get_all()
            actions_registrar.register_actions(packs_base_paths=[packs_base_path])
        except Exception as e:
            print(str(e))
            self.fail('All actions must be registered without exceptions.')
        else: