def test_add_default_templates_to_live_params(self):
        """Test addition of template values in defaults to live params"""

        # Ensure parameter is skipped if the parameter has immutable set to true in schema
        schemas = [
            {
                "templateparam": {
                    "default": "{{ 3 | int }}",
                    "type": "integer",
                    "immutable": True,
                }
            }
        ]
        context = {"templateparam": "3"}
        result = param_utils._cast_params_from({}, context, schemas)
        self.assertEqual(result, {})

        # Test with no live params, and two parameters - one should make it through because
        # it was a template, and the other shouldn't because its default wasn't a template
        schemas = [{"templateparam": {"default": "{{ 3 | int }}", "type": "integer"}}]
        context = {"templateparam": "3"}
        result = param_utils._cast_params_from({}, context, schemas)
        self.assertEqual(result, {"templateparam": 3})

        # Ensure parameter is skipped if the value in context is identical to default
        schemas = [{"nottemplateparam": {"default": "4", "type": "integer"}}]
        context = {
            "nottemplateparam": "4",
        }
        result = param_utils._cast_params_from({}, context, schemas)
        self.assertEqual(result, {})

        # Ensure parameter is skipped if the parameter doesn't have a default
        schemas = [{"nottemplateparam": {"type": "integer"}}]
        context = {
            "nottemplateparam": "4",
        }
        result = param_utils._cast_params_from({}, context, schemas)
        self.assertEqual(result, {})

        # Skip if the default value isn't a Jinja expression
        schemas = [{"nottemplateparam": {"default": "5", "type": "integer"}}]
        context = {
            "nottemplateparam": "4",
        }
        result = param_utils._cast_params_from({}, context, schemas)
        self.assertEqual(result, {})

        # Ensure parameter is skipped if the parameter is being overridden
        schemas = [{"templateparam": {"default": "{{ 3 | int }}", "type": "integer"}}]
        context = {
            "templateparam": "4",
        }
        result = param_utils._cast_params_from({"templateparam": "4"}, context, schemas)
        self.assertEqual(result, {"templateparam": 4})
Test addition of template values in defaults to live params
st2common/tests/unit/test_param_utils.py