Beispiel #1
0
    def test_run_action_with_kwargs_input(self, run_mock, class_mock,
                                          validate_mock, def_mock):
        action_def = models.ActionDefinition()
        action_def.update({
            'name': 'fake_action',
            'action_class': '',
            'attributes': {},
            'description': '',
            'input': '**kwargs',
            'is_system': True,
            'scope': 'public'
        })
        def_mock.return_value = action_def
        run_mock.return_value = wf_utils.Result(data='Hello')

        class_ret = mock.MagicMock()
        class_mock.return_value = class_ret

        self.engine.start_action('fake_action', {'input': 'Hello'})

        self.assertEqual(1, def_mock.call_count)
        def_mock.assert_called_with('fake_action')

        self.assertEqual(0, validate_mock.call_count)

        class_ret.assert_called_once_with(input='Hello')

        run_mock.assert_called_once_with({'input': 'Hello'}, None, save=False)
Beispiel #2
0
def create_action_definition(values, session=None):
    a_def = models.ActionDefinition()

    a_def.update(values)

    try:
        a_def.save(session=session)
    except db_exc.DBDuplicateEntry as e:
        raise exc.DBDuplicateEntryError("Duplicate entry for action %s: %s" %
                                        (a_def.name, e.columns))

    return a_def
Beispiel #3
0
def create_action_definition(values, session=None):
    a_def = models.ActionDefinition()

    a_def.update(values)

    try:
        a_def.save(session=session)
    except db_exc.DBDuplicateEntry:
        raise exc.DBDuplicateEntryError(
            "Duplicate entry for Action ['name', 'project_id']:"
            " {}, {}".format(a_def.name, a_def.project_id))

    return a_def
Beispiel #4
0
    'name': 'step',
    'is_system': False,
    'description': 'My super cool action.',
    'tags': ['test', 'v2'],
    'definition': ''
}

WF = {
    'id': '123e4567-e89b-12d3-a456-426655440000',
    'name': 'flow',
    'definition': '',
    'created_at': '1970-01-01 00:00:00',
    'updated_at': '1970-01-01 00:00:00',
}

ACTION_DB = models.ActionDefinition()
ACTION_DB.update(ACTION)

WORKBOOK_DB = models.Workbook()
WORKBOOK_DB.update(WORKBOOK)

WB_DB_WITH_NAMESPACE = models.Workbook(**WB_WITH_NAMESPACE)

WF_DB = models.WorkflowDefinition()
WF_DB.update(WF)

WORKBOOK_DB_PROJECT_ID = WORKBOOK_DB.get_clone()
WORKBOOK_DB_PROJECT_ID.project_id = '<default-project>'

UPDATED_WORKBOOK_DB = copy.copy(WORKBOOK_DB)
UPDATED_WORKBOOK_DB['definition'] = UPDATED_WORKBOOK_DEF
Beispiel #5
0
    'id': '123e4567-e89b-12d3-a456-426655440000',
    'name': 'my_action',
    'is_system': False,
    'description': 'My super cool action.',
    'tags': ['test', 'v2'],
    'definition': ACTION_DEFINITION
}

SYSTEM_ACTION = {
    'id': '1234',
    'name': 'std.echo',
    'is_system': True,
    'definition': SYSTEM_ACTION_DEFINITION
}

ACTION_DB = models.ActionDefinition()
ACTION_DB.update(ACTION)

SYSTEM_ACTION_DB = models.ActionDefinition()
SYSTEM_ACTION_DB.update(SYSTEM_ACTION)

UPDATED_ACTION_DEFINITION = """
---
version: '2.0'

my_action:
  description: My super cool action.
  base: std.echo
  base-input:
    output: "{$.str1}{$.str2}{$.str3}"
"""
Beispiel #6
0
ADHOC_ACTION_YAML = """
---
version: '2.0'

my_action:
  description: My super cool action.
  tags: ['test', 'v2']
  base: std.echo
  base-input:
    output: "{$.str1}{$.str2}"
"""

ADHOC_ACTION_DEF = models.ActionDefinition(
    id='123e4567-e89b-12d3-a456-426655440000',
    name='my_action',
    is_system=False,
    description='My super cool action.',
    tags=['test', 'v2'],
    definition=ADHOC_ACTION_YAML)

MOCK_ACTION = mock.MagicMock(return_value=ADHOC_ACTION_DEF)


class TestActionPolicy(base.APITest):
    """Test action related policies

    Policies to test:
    - actions:create
    - actions:delete
    - actions:get
    - actions:list