diff --git a/murano/dsl/yaql_expression.py b/murano/dsl/yaql_expression.py index f84f9c14..c03d9265 100644 --- a/murano/dsl/yaql_expression.py +++ b/murano/dsl/yaql_expression.py @@ -15,6 +15,8 @@ import re import types +from oslo_utils import encodeutils + import yaql import yaql.exceptions import yaql.expressions @@ -23,7 +25,7 @@ import yaql.expressions class YaqlExpression(object): def __init__(self, expression): if isinstance(expression, types.StringTypes): - self._expression = str(expression) + self._expression = encodeutils.safe_encode(expression) self._parsed_expression = yaql.parse(self._expression) self._file_position = None elif isinstance(expression, YaqlExpression): diff --git a/murano/tests/unit/test_engine.py b/murano/tests/unit/test_engine.py index d8e56acd..9d38b885 100644 --- a/murano/tests/unit/test_engine.py +++ b/murano/tests/unit/test_engine.py @@ -1,3 +1,4 @@ +# coding: utf-8 # Copyright (c) 2014 Mirantis Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -164,6 +165,19 @@ class TestYaqlExpression(base.MuranoTestCase): self.assertEqual('string', yaql_expr.expression) + def test_unicode_expression(self): + yaql_expr = yaql_expression.YaqlExpression(u"'yaql ♥ unicode'") + + self.assertEqual(u"'yaql ♥ unicode'".encode('utf-8'), + yaql_expr.expression) + + def test_unicode_expression_expression(self): + yaql_expr = yaql_expression.YaqlExpression(u"'yaql ♥ unicode'") + yaql_expr2 = yaql_expression.YaqlExpression(yaql_expr) + + self.assertEqual(u"'yaql ♥ unicode'".encode('utf-8'), + yaql_expr2.expression) + def test_evaluate_calls(self): string = 'string' expected_calls = [mock.call(string),