Add action "std.test_dict"
* It can be useful for various tests with big data * Minor cosmetic changes Change-Id: I34f568c4b7eee4485a5942fa59a1f57d735b38a7
This commit is contained in:
parent
f190b5e04b
commit
0653e408e4
@ -463,3 +463,28 @@ class SleepAction(base.Action):
|
||||
time.sleep(1)
|
||||
|
||||
return None
|
||||
|
||||
|
||||
class TestDictAction(base.Action):
|
||||
"""Generates test dict."""
|
||||
|
||||
def __init__(self, size=0, key_prefix='', val=''):
|
||||
self.size = size
|
||||
self.key_prefix = key_prefix
|
||||
self.val = val
|
||||
|
||||
def run(self):
|
||||
LOG.info(
|
||||
'Running test_dict action [size=%s, key_prefix=%s, val=%s]' %
|
||||
(self.size, self.key_prefix, self.val)
|
||||
)
|
||||
|
||||
res = {}
|
||||
|
||||
for i in range(self.size):
|
||||
res['%s%s' % (self.key_prefix, i)] = self.val
|
||||
|
||||
return res
|
||||
|
||||
def test(self):
|
||||
return {}
|
||||
|
@ -33,6 +33,7 @@ def get_yaql_context(data_context):
|
||||
ROOT_YAQL_CONTEXT = yaql.create_context()
|
||||
|
||||
_register_yaql_functions(ROOT_YAQL_CONTEXT)
|
||||
|
||||
new_ctx = ROOT_YAQL_CONTEXT.create_child_context()
|
||||
new_ctx['$'] = data_context
|
||||
|
||||
@ -62,7 +63,7 @@ def get_jinja_context(data_context):
|
||||
def get_custom_functions():
|
||||
"""Get custom functions
|
||||
|
||||
Retreives the list of custom evaluation functions
|
||||
Retrieves the list of custom evaluation functions
|
||||
"""
|
||||
functions = dict()
|
||||
|
||||
@ -70,6 +71,7 @@ def get_custom_functions():
|
||||
namespace='mistral.expression.functions',
|
||||
invoke_on_load=False
|
||||
)
|
||||
|
||||
for name in mgr.names():
|
||||
functions[name] = mgr[name].plugin
|
||||
|
||||
@ -118,7 +120,6 @@ def json_pp_(context, data=None):
|
||||
|
||||
|
||||
def task_(context, task_name):
|
||||
|
||||
# This section may not exist in a context if it's calculated not in
|
||||
# task scope.
|
||||
cur_task = context['__task_execution']
|
||||
|
@ -69,6 +69,7 @@ mistral.actions =
|
||||
std.javascript = mistral.actions.std_actions:JavaScriptAction
|
||||
std.js = mistral.actions.std_actions:JavaScriptAction
|
||||
std.sleep = mistral.actions.std_actions:SleepAction
|
||||
std.test_dict = mistral.actions.std_actions:TestDictAction
|
||||
|
||||
mistral.expression.functions =
|
||||
json_pp = mistral.utils.expression_utils:json_pp_
|
||||
|
Loading…
x
Reference in New Issue
Block a user