From d55ed99b5051a1e076336780e386a4eb23c56eeb Mon Sep 17 00:00:00 2001 From: Nikolay Mahotkin Date: Thu, 7 May 2015 14:42:33 +0300 Subject: [PATCH] Fixing YAQL related errors * Now Mistral raises YaqlEvaluationException if something was wrong with evaluating YAQL. Closes-Bug: #1449505 Change-Id: Ic6a1592b8424ebdbaaca698b9a894d589def97d2 --- mistral/expressions.py | 2 +- .../tests/unit/engine/test_direct_workflow.py | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/mistral/expressions.py b/mistral/expressions.py index d6196097..6b5e6d51 100644 --- a/mistral/expressions.py +++ b/mistral/expressions.py @@ -89,7 +89,7 @@ class YAQLEvaluator(Evaluator): data=data_context, context=yaql_utils.create_yaql_context() ) - except (KeyError, yaql_exc.YaqlException) as e: + except (yaql_exc.YaqlException, KeyError, ValueError, TypeError) as e: raise exc.YaqlEvaluationException( "Can not evaluate YAQL expression: %s, data = %s; error:" " %s" % (expression, data_context, str(e)) diff --git a/mistral/tests/unit/engine/test_direct_workflow.py b/mistral/tests/unit/engine/test_direct_workflow.py index 021e3495..5baf639f 100644 --- a/mistral/tests/unit/engine/test_direct_workflow.py +++ b/mistral/tests/unit/engine/test_direct_workflow.py @@ -262,6 +262,27 @@ class DirectWorkflowEngineTest(base.EngineTestCase): "Called with a right exception" ) + def test_mismatched_yaql_in_first_task(self): + wf_text = """ + version: '2.0' + + wf: + input: + - var + tasks: + task1: + action: std.echo output=<% $.var + $.var2 %> + """ + + wf_service.create_workflows(wf_text) + + exception = self.assertRaises( + exc.YaqlEvaluationException, + self.engine.start_workflow, 'wf', {'var': 2} + ) + + self.assertIn("Can not evaluate YAQL expression", exception.message) + def test_one_line_syntax_in_on_clauses(self): wf_text = """ version: '2.0'