当前位置: 首页>>代码示例>>Python>>正文


Python param.get_finalized_params函数代码示例

本文整理汇总了Python中st2common.util.param.get_finalized_params函数的典型用法代码示例。如果您正苦于以下问题:Python get_finalized_params函数的具体用法?Python get_finalized_params怎么用?Python get_finalized_params使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_finalized_params函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_get_finalized_params_with_missing_dependency

    def test_get_finalized_params_with_missing_dependency(self):
        params = {'r1': '{{r3}}', 'r2': '{{r3}}'}
        runner_param_info = {'r1': {}, 'r2': {}}
        action_param_info = {}
        test_pass = True
        try:
            param_utils.get_finalized_params(runner_param_info,
                                             action_param_info,
                                             params,
                                             {'user': None})
            test_pass = False
        except ParamException as e:
            test_pass = six.text_type(e).find('Dependency') == 0
        self.assertTrue(test_pass)

        params = {}
        runner_param_info = {'r1': {'default': '{{r3}}'}, 'r2': {'default': '{{r3}}'}}
        action_param_info = {}
        test_pass = True
        try:
            param_utils.get_finalized_params(runner_param_info,
                                             action_param_info,
                                             params,
                                             {'user': None})
            test_pass = False
        except ParamException as e:
            test_pass = six.text_type(e).find('Dependency') == 0
        self.assertTrue(test_pass)
开发者ID:mahak,项目名称:st2,代码行数:28,代码来源:test_param_utils.py

示例2: test_get_finalized_params_order

    def test_get_finalized_params_order(self):
        params = {
            'r1': 'p1',
            'r2': 'p2',
            'r3': 'p3',
            'a1': 'p4',
            'a2': 'p5'
        }
        runner_param_info = {'r1': {}, 'r2': {'default': 'r2'}, 'r3': {'default': 'r3'}}
        action_param_info = {'a1': {}, 'a2': {'default': 'a2'}, 'r3': {'default': 'a3'}}
        action_context = {'api_user': 'noob'}
        r_runner_params, r_action_params = param_utils.get_finalized_params(
            runner_param_info, action_param_info, params, action_context)
        self.assertEqual(r_runner_params, {'r1': u'p1', 'r2': u'p2', 'r3': u'p3'})
        self.assertEqual(r_action_params, {'a1': u'p4', 'a2': u'p5'})

        params = {}
        runner_param_info = {'r1': {}, 'r2': {'default': 'r2'}, 'r3': {'default': 'r3'}}
        action_param_info = {'a1': {}, 'a2': {'default': 'a2'}, 'r3': {'default': 'a3'}}
        action_context = {'api_user': 'noob'}
        r_runner_params, r_action_params = param_utils.get_finalized_params(
            runner_param_info, action_param_info, params, action_context)
        self.assertEqual(r_runner_params, {'r1': None, 'r2': u'r2', 'r3': u'a3'})
        self.assertEqual(r_action_params, {'a1': None, 'a2': u'a2'})

        params = {}
        runner_param_info = {'r1': {}, 'r2': {'default': 'r2'}, 'r3': {}}
        action_param_info = {'r1': {}, 'r2': {}, 'r3': {'default': 'a3'}}
        action_context = {'api_user': 'noob'}
        r_runner_params, r_action_params = param_utils.get_finalized_params(
            runner_param_info, action_param_info, params, action_context)
        self.assertEqual(r_runner_params, {'r1': None, 'r2': u'r2', 'r3': u'a3'})
开发者ID:tonybaloney,项目名称:st2,代码行数:32,代码来源:test_param_utils.py

示例3: test_get_finalized_params_order

    def test_get_finalized_params_order(self):
        params = {"r1": "p1", "r2": "p2", "r3": "p3", "a1": "p4", "a2": "p5"}
        runner_param_info = {"r1": {}, "r2": {"default": "r2"}, "r3": {"default": "r3"}}
        action_param_info = {"a1": {}, "a2": {"default": "a2"}, "r3": {"default": "a3"}}
        action_context = {"api_user": "noob"}
        r_runner_params, r_action_params = param_utils.get_finalized_params(
            runner_param_info, action_param_info, params, action_context
        )
        self.assertEqual(r_runner_params, {"r1": u"p1", "r2": u"p2", "r3": u"p3"})
        self.assertEqual(r_action_params, {"a1": u"p4", "a2": u"p5"})

        params = {}
        runner_param_info = {"r1": {}, "r2": {"default": "r2"}, "r3": {"default": "r3"}}
        action_param_info = {"a1": {}, "a2": {"default": "a2"}, "r3": {"default": "a3"}}
        action_context = {"api_user": "noob"}
        r_runner_params, r_action_params = param_utils.get_finalized_params(
            runner_param_info, action_param_info, params, action_context
        )
        self.assertEqual(r_runner_params, {"r1": None, "r2": u"r2", "r3": u"a3"})
        self.assertEqual(r_action_params, {"a1": None, "a2": u"a2"})

        params = {}
        runner_param_info = {"r1": {}, "r2": {"default": "r2"}, "r3": {}}
        action_param_info = {"r1": {}, "r2": {}, "r3": {"default": "a3"}}
        action_context = {"api_user": "noob"}
        r_runner_params, r_action_params = param_utils.get_finalized_params(
            runner_param_info, action_param_info, params, action_context
        )
        self.assertEqual(r_runner_params, {"r1": None, "r2": u"r2", "r3": u"a3"})
开发者ID:Pulsant,项目名称:st2,代码行数:29,代码来源:test_param_utils.py

示例4: test_get_finalized_params_with_cyclic_dependency

 def test_get_finalized_params_with_cyclic_dependency(self):
     params = {'r1': '{{r2}}', 'r2': '{{r1}}'}
     runner_param_info = {'r1': {}, 'r2': {}}
     action_param_info = {}
     test_pass = True
     try:
         param_utils.get_finalized_params(runner_param_info, action_param_info, params, {})
         test_pass = False
     except ParamException as e:
         test_pass = e.message.find('Cyclic') == 0
     self.assertTrue(test_pass)
开发者ID:tonybaloney,项目名称:st2,代码行数:11,代码来源:test_param_utils.py

示例5: test_get_finalized_params_with_list

 def test_get_finalized_params_with_list(self):
     # Note : In this test runner_params.r1 has a string value. However per runner_param_info the
     # type is an integer. The expected type is considered and cast is performed accordingly.
     params = {
         'r1': '{{r2}}',
         'r2': ['1', '2'],
         'a1': True,
         'a2': 'Test',
         'a3': 'Test2',
         'a4': '{{a1}}',
         'a5': ['{{a2}}', '{{a3}}']
     }
     runner_param_info = {'r1': {'type': 'array'}, 'r2': {'type': 'array'}}
     action_param_info = {
         'a1': {'type': 'boolean'},
         'a2': {'type': 'string'},
         'a3': {'type': 'string'},
         'a4': {'type': 'boolean'},
         'a5': {'type': 'array'}
     }
     r_runner_params, r_action_params = param_utils.get_finalized_params(
         runner_param_info, action_param_info, params, {})
     self.assertEqual(r_runner_params, {'r1': ['1', '2'], 'r2': ['1', '2']})
     self.assertEqual(
         r_action_params,
         {
             'a1': True,
             'a2': 'Test',
             'a3': 'Test2',
             'a4': True,
             'a5': ['Test', 'Test2']
         }
     )
开发者ID:tonybaloney,项目名称:st2,代码行数:33,代码来源:test_param_utils.py

示例6: test_get_finalized_params_system_values

    def test_get_finalized_params_system_values(self):
        KeyValuePair.add_or_update(KeyValuePairDB(name='actionstr', value='foo'))
        KeyValuePair.add_or_update(KeyValuePairDB(name='actionnumber', value='1.0'))
        params = {
            'runnerint': 555
        }
        liveaction_db = self._get_liveaction_model(params)

        runner_params, action_params = param_utils.get_finalized_params(
            ParamsUtilsTest.runnertype_db.runner_parameters,
            ParamsUtilsTest.action_system_default_db.parameters,
            liveaction_db.parameters,
            liveaction_db.context)

        # Asserts for runner params.
        # Assert that default values for runner params are resolved.
        self.assertEqual(runner_params.get('runnerstr'), 'defaultfoo')
        # Assert that a runner param from action exec is picked up.
        self.assertEqual(runner_params.get('runnerint'), 555)
        # Assert that an immutable param cannot be overridden by action param or execution param.
        self.assertEqual(runner_params.get('runnerimmutable'), 'runnerimmutable')

        # Asserts for action params.
        self.assertEqual(action_params.get('actionstr'), 'foo')
        self.assertEqual(action_params.get('actionnumber'), 1.0)
开发者ID:tonybaloney,项目名称:st2,代码行数:25,代码来源:test_param_utils.py

示例7: test_get_finalized_params_action_immutable

    def test_get_finalized_params_action_immutable(self):
        params = {
            "actionstr": "foo",
            "some_key_that_aint_exist_in_action_or_runner": "bar",
            "runnerint": 555,
            "actionimmutable": "failed_override",
        }
        liveaction_db = self._get_liveaction_model(params)
        action_context = {"api_user": None}

        runner_params, action_params = param_utils.get_finalized_params(
            ParamsUtilsTest.runnertype_db.runner_parameters,
            ParamsUtilsTest.action_db.parameters,
            liveaction_db.parameters,
            action_context,
        )

        # Asserts for runner params.
        # Assert that default values for runner params are resolved.
        self.assertEqual(runner_params.get("runnerstr"), "defaultfoo")
        # Assert that a runner param from action exec is picked up.
        self.assertEqual(runner_params.get("runnerint"), 555)
        # Assert that a runner param can be overridden by action param default.
        self.assertEqual(runner_params.get("runnerdummy"), "actiondummy")

        # Asserts for action params.
        self.assertEqual(action_params.get("actionstr"), "foo")
        # Assert that a param that is provided in action exec that isn't in action or runner params
        # isn't in resolved params.
        self.assertEqual(action_params.get("some_key_that_aint_exist_in_action_or_runner"), None)
开发者ID:Pulsant,项目名称:st2,代码行数:30,代码来源:test_param_utils.py

示例8: test_get_finalized_params_with_list

 def test_get_finalized_params_with_list(self):
     # Note : In this test runner_params.r1 has a string value. However per runner_param_info the
     # type is an integer. The expected type is considered and cast is performed accordingly.
     params = {
         "r1": "{{r2}}",
         "r2": ["1", "2"],
         "a1": True,
         "a2": "Test",
         "a3": "Test2",
         "a4": "{{a1}}",
         "a5": ["{{a2}}", "{{a3}}"],
     }
     runner_param_info = {"r1": {"type": "array"}, "r2": {"type": "array"}}
     action_param_info = {
         "a1": {"type": "boolean"},
         "a2": {"type": "string"},
         "a3": {"type": "string"},
         "a4": {"type": "boolean"},
         "a5": {"type": "array"},
     }
     r_runner_params, r_action_params = param_utils.get_finalized_params(
         runner_param_info, action_param_info, params, {}
     )
     self.assertEqual(r_runner_params, {"r1": ["1", "2"], "r2": ["1", "2"]})
     self.assertEqual(
         r_action_params, {"a1": True, "a2": "Test", "a3": "Test2", "a4": True, "a5": ["Test", "Test2"]}
     )
开发者ID:Pulsant,项目名称:st2,代码行数:27,代码来源:test_param_utils.py

示例9: test_get_finalized_params_action_immutable

    def test_get_finalized_params_action_immutable(self):
        params = {
            'actionstr': 'foo',
            'some_key_that_aint_exist_in_action_or_runner': 'bar',
            'runnerint': 555,
            'actionimmutable': 'failed_override'
        }
        liveaction_db = self._get_liveaction_model(params)
        action_context = {'api_user': None}

        runner_params, action_params = param_utils.get_finalized_params(
            ParamsUtilsTest.runnertype_db.runner_parameters,
            ParamsUtilsTest.action_db.parameters,
            liveaction_db.parameters,
            action_context)

        # Asserts for runner params.
        # Assert that default values for runner params are resolved.
        self.assertEqual(runner_params.get('runnerstr'), 'defaultfoo')
        # Assert that a runner param from action exec is picked up.
        self.assertEqual(runner_params.get('runnerint'), 555)
        # Assert that a runner param can be overridden by action param default.
        self.assertEqual(runner_params.get('runnerdummy'), 'actiondummy')

        # Asserts for action params.
        self.assertEqual(action_params.get('actionstr'), 'foo')
        # Assert that a param that is provided in action exec that isn't in action or runner params
        # isn't in resolved params.
        self.assertEqual(action_params.get('some_key_that_aint_exist_in_action_or_runner'), None)
开发者ID:tonybaloney,项目名称:st2,代码行数:29,代码来源:test_param_utils.py

示例10: test_get_finalized_param_object_contains_template_notation_in_the_value

    def test_get_finalized_param_object_contains_template_notation_in_the_value(self):
        runner_param_info = {'r1': {}}
        action_param_info = {
            'params': {
                'type': 'object',
                'default': {
                    'host': '{{host}}',
                    'port': '{{port}}',
                    'path': '/bar'}
            }
        }
        params = {
            'host': 'lolcathost',
            'port': 5555
        }
        action_context = {}

        r_runner_params, r_action_params = param_utils.get_finalized_params(
            runner_param_info, action_param_info, params, action_context)

        expected_params = {
            'host': 'lolcathost',
            'port': '5555',
            'path': '/bar'
        }
        self.assertEqual(r_action_params['params'], expected_params)
开发者ID:pixelrebel,项目名称:st2,代码行数:26,代码来源:test_param_utils.py

示例11: test_get_finalized_params_with_dict

 def test_get_finalized_params_with_dict(self):
     # Note : In this test runner_params.r1 has a string value. However per runner_param_info the
     # type is an integer. The expected type is considered and cast is performed accordingly.
     params = {
         'r1': '{{r2}}',
         'r2': {'r2.1': 1},
         'a1': True,
         'a2': '{{a1}}',
         'a3': {
             'test': '{{a1}}',
             'test1': '{{a4}}',
             'test2': '{{a5}}',
         },
         'a4': 3,
         'a5': ['1', '{{a1}}']
     }
     runner_param_info = {'r1': {'type': 'object'}, 'r2': {'type': 'object'}}
     action_param_info = {
         'a1': {
             'type': 'boolean',
         },
         'a2': {
             'type': 'boolean',
         },
         'a3': {
             'type': 'object',
         },
         'a4': {
             'type': 'integer',
         },
         'a5': {
             'type': 'array',
         },
     }
     r_runner_params, r_action_params = param_utils.get_finalized_params(
         runner_param_info, action_param_info, params, {})
     self.assertEqual(
         r_runner_params, {'r1': {'r2.1': 1}, 'r2': {'r2.1': 1}})
     self.assertEqual(
         r_action_params,
         {
             'a1': True,
             'a2': True,
             'a3': {
                 'test': True,
                 'test1': 3,
                 'test2': [
                     '1',
                     True
                 ],
             },
             'a4': 3,
             'a5': [
                 '1',
                 True
             ],
         }
     )
开发者ID:lyandut,项目名称:st2,代码行数:58,代码来源:test_param_utils.py

示例12: test_get_finalized_params_empty

 def test_get_finalized_params_empty(self):
     params = {}
     runner_param_info = {}
     action_param_info = {}
     action_context = {}
     r_runner_params, r_action_params = param_utils.get_finalized_params(
         runner_param_info, action_param_info, params, action_context)
     self.assertEqual(r_runner_params, params)
     self.assertEqual(r_action_params, params)
开发者ID:tonybaloney,项目名称:st2,代码行数:9,代码来源:test_param_utils.py

示例13: test_get_finalized_params_with_list

 def test_get_finalized_params_with_list(self):
     # Note : In this test runner_params.r1 has a string value. However per runner_param_info the
     # type is an integer. The expected type is considered and cast is performed accordingly.
     self.maxDiff = None
     params = {
         'r1': '{{r2}}',
         'r2': ['1', '2'],
         'a1': True,
         'a2': 'Test',
         'a3': 'Test2',
         'a4': '{{a1}}',
         'a5': ['{{a2}}', '{{a3}}'],
         'a6': [
             ['{{r2}}', '{{a2}}'],
             ['{{a3}}', '{{a1}}'],
             [
                 '{{a7}}',
                 'This should be rendered as a string {{a1}}',
                 '{{a1}} This, too, should be rendered as a string {{a1}}',
             ]
         ],
         'a7': 5,
     }
     runner_param_info = {'r1': {'type': 'array'}, 'r2': {'type': 'array'}}
     action_param_info = {
         'a1': {'type': 'boolean'},
         'a2': {'type': 'string'},
         'a3': {'type': 'string'},
         'a4': {'type': 'boolean'},
         'a5': {'type': 'array'},
         'a6': {'type': 'array'},
         'a7': {'type': 'integer'},
     }
     r_runner_params, r_action_params = param_utils.get_finalized_params(
         runner_param_info, action_param_info, params, {})
     self.assertEqual(r_runner_params, {'r1': ['1', '2'], 'r2': ['1', '2']})
     self.assertEqual(
         r_action_params,
         {
             'a1': True,
             'a2': 'Test',
             'a3': 'Test2',
             'a4': True,
             'a5': ['Test', 'Test2'],
             'a6': [
                 [['1', '2'], 'Test'],
                 ['Test2', True],
                 [
                     5,
                     u'This should be rendered as a string True',
                     u'True This, too, should be rendered as a string True'
                 ]
             ],
             'a7': 5,
         }
     )
开发者ID:lyandut,项目名称:st2,代码行数:56,代码来源:test_param_utils.py

示例14: test_get_finalized_params_jinja_filters

    def test_get_finalized_params_jinja_filters(self):
        params = {'cmd': 'echo {{"1.6.0" | version_bump_minor}}'}
        runner_param_info = {'r1': {}}
        action_param_info = {'cmd': {}}
        action_context = {}

        r_runner_params, r_action_params = param_utils.get_finalized_params(
            runner_param_info, action_param_info, params, action_context)

        self.assertEqual(r_action_params['cmd'], "echo 1.7.0")
开发者ID:tonybaloney,项目名称:st2,代码行数:10,代码来源:test_param_utils.py

示例15: test_get_finalized_params_no_double_rendering

 def test_get_finalized_params_no_double_rendering(self):
     params = {"r1": "{{ action_context.h1 }}{{ action_context.h2 }}"}
     runner_param_info = {"r1": {}}
     action_param_info = {}
     action_context = {"h1": "{", "h2": "{ missing }}"}
     r_runner_params, r_action_params = param_utils.get_finalized_params(
         runner_param_info, action_param_info, params, action_context
     )
     self.assertEqual(r_runner_params, {"r1": "{{ missing }}"})
     self.assertEqual(r_action_params, {})
开发者ID:Pulsant,项目名称:st2,代码行数:10,代码来源:test_param_utils.py


注:本文中的st2common.util.param.get_finalized_params函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。