Beispiel #1
0
    def test_get_input_dict_from_string(self):
        self.assertDictEqual(
            {
                'param1': utils.NotDefined,
                'param2': 2,
                'param3': 'var3'
            }, utils.get_dict_from_string('param1, param2=2, param3="var3"'))

        self.assertDictEqual({}, utils.get_dict_from_string(''))
Beispiel #2
0
    def test_get_all_pagination(self):
        # Create an adhoc action for the purpose of the test.
        adhoc_actions.create_actions(ADHOC_ACTION_YAML)

        resp = self.app.get('/v2/actions?limit=1&sort_keys=id,name')

        self.assertEqual(200, resp.status_int)
        self.assertIn('next', resp.json)
        self.assertEqual(1, len(resp.json['actions']))

        self.check_adhoc_action_json(resp.json['actions'][0])

        param_dict = utils.get_dict_from_string(
            resp.json['next'].split('?')[1],
            delimiter='&'
        )

        action_def = db_api.get_action_definition('my_action')

        # TODO(rakhmerov): In this case we can't use IDs for marker because
        # in general we don't identify action descriptors with IDs.
        expected_dict = {
            'marker': action_def.id,
            'limit': 1,
            'sort_keys': 'id,name',
            'sort_dirs': 'asc,asc'
        }

        self.assertTrue(
            set(expected_dict.items()).issubset(set(param_dict.items()))
        )
Beispiel #3
0
    def validate_input(self, input_dict):
        # NOTE(kong): Don't validate action input if action initialization
        # method contains ** argument.
        if '**' in self.action_def.input:
            return

        expected_input = utils.get_dict_from_string(self.action_def.input)

        engine_utils.validate_input(expected_input, input_dict,
                                    self.action_def.name,
                                    self.action_def.action_class)
Beispiel #4
0
    def test_get_all_pagination(self):
        resp = self.app.get('/v2/executions?limit=1&sort_keys=id,workflow_name'
                            '&sort_dirs=asc,desc')

        self.assertEqual(200, resp.status_int)
        self.assertIn('next', resp.json)
        self.assertEqual(1, len(resp.json['executions']))
        self.assertDictEqual(WF_EX_JSON_WITH_DESC, resp.json['executions'][0])

        param_dict = utils.get_dict_from_string(
            resp.json['next'].split('?')[1], delimiter='&')

        expected_dict = {
            'marker': '123e4567-e89b-12d3-a456-426655440000',
            'limit': 1,
            'sort_keys': 'id,workflow_name',
            'sort_dirs': 'asc,desc'
        }

        self.assertDictEqual(expected_dict, param_dict)
Beispiel #5
0
    def test_get_all_pagination(self):
        resp = self.app.get('/v2/actions?limit=1&sort_keys=id,name')

        self.assertEqual(200, resp.status_int)
        self.assertIn('next', resp.json)
        self.assertEqual(1, len(resp.json['actions']))
        self.assertDictEqual(ACTION, resp.json['actions'][0])

        param_dict = utils.get_dict_from_string(
            resp.json['next'].split('?')[1], delimiter='&')

        expected_dict = {
            'marker': '123e4567-e89b-12d3-a456-426655440000',
            'limit': 1,
            'sort_keys': 'id,name',
            'sort_dirs': 'asc,asc'
        }

        self.assertTrue(
            set(expected_dict.items()).issubset(set(param_dict.items())))