Esempio n. 1
0
 def test_convert_expression_yaql_st2kv_user(self):
     expr = '<% st2kv.user.test.kv %>'
     result = YaqlExpressionConverter.convert_string(expr)
     self.assertEqual(result, "<% st2kv('user.test.kv') %>")
Esempio n. 2
0
 def test_convert_expression_yaql_st2_api_url(self):
     expr = '<% env().st2_action_api_url %>'
     result = YaqlExpressionConverter.convert_string(expr)
     self.assertEqual(result, "<% ctx().st2.api_url %>")
Esempio n. 3
0
 def test_convert_expression_yaql_task_result_single_quote(self):
     expr = "<% task('abc').result.result %>"
     result = YaqlExpressionConverter.convert_string(expr)
     self.assertEqual(result, "<% result().result %>")
Esempio n. 4
0
 def test_convert_expression_yaql_task_result_double_quotes(self):
     expr = '<% task("abc").result.double_quote %>'
     result = YaqlExpressionConverter.convert_string(expr)
     self.assertEqual(result, "<% result().double_quote %>")
Esempio n. 5
0
 def test_convert_expression_yaql_context_vars_multiple(self):
     expr = "<% $.test + $.other %>"
     result = YaqlExpressionConverter.convert_string(expr)
     self.assertEqual(result, "<% ctx().test + ctx().other %>")
Esempio n. 6
0
 def test_convert_expression_yaql_context_vars_with_underscore(self):
     expr = "<% $.test_.other %>"
     result = YaqlExpressionConverter.convert_string(expr)
     self.assertEqual(result, "<% ctx().test_.other %>")
Esempio n. 7
0
 def test_convert_expression_yaql_function_context_vars(self):
     expr = "<% list(range(0, $.count)) %>"
     result = YaqlExpressionConverter.convert_string(expr)
     self.assertEqual(result, "<% list(range(0, ctx().count)) %>")
Esempio n. 8
0
 def test_convert_expression_yaql_complex_function_context_vars(self):
     expr = "<% zip([0, 1, 2], [3, 4, 5], $.all_the_things) %>"
     result = YaqlExpressionConverter.convert_string(expr)
     self.assertEqual(
         result, "<% zip([0, 1, 2], [3, 4, 5], ctx().all_the_things) %>")
Esempio n. 9
0
 def test_convert_expression_yaql_context_and_item_vars(self):
     expr = "<% $.test + $.test2 - $.long_var %>"
     result = YaqlExpressionConverter.convert_string(expr,
                                                     item_vars=['test'])
     self.assertEqual(result,
                      "<% item(test) + ctx().test2 - ctx().long_var %>")
Esempio n. 10
0
 def test_convert_expression_yaql_item_vars(self):
     expr = "<% $.test %>"
     result = YaqlExpressionConverter.convert_string(expr,
                                                     item_vars=['test'])
     self.assertEqual(result, "<% item(test) %>")
Esempio n. 11
0
 def test_convert_expression_yaql_task_result(self):
     expr = "<% task(abc).result.result %>"
     result = YaqlExpressionConverter.convert_string(expr)
     self.assertEquals(result, "<% result().result %>")
Esempio n. 12
0
 def test_convert_expression_yaql_context_vars(self):
     expr = "<% $.test %>"
     result = YaqlExpressionConverter.convert_string(expr)
     self.assertEquals(result, "<% ctx().test %>")
Esempio n. 13
0
 def test_convert_expression_yaql_st2_execution_id(self):
     expr = '<% env().st2_execution_id %>'
     result = YaqlExpressionConverter.convert_string(expr)
     self.assertEquals(result, "<% ctx().st2.action_execution_id %>")