wrapped the value of parameters in inputs(in wf get API) with "".
the input field of workflow-get API is ambiguous, and not well defined, 2 different inputs can have the same value for the input field. for example : input: - first - second: "value, third" and: input: - first - second: "value" - third for both it was: input ="first, second=value, third" now it is: for the first: input ="first, second=\"value, third\"" and for the second: input ="first, second=\"value\", third" Closes-Bug: 1631541 Change-Id: I4b3fc7e0ad4552022d44c3bdd8c87004f5e8ff46 Signed-off-by: ali <ali.abdelal@nokia.com>
This commit is contained in:
parent
5e90c610f8
commit
4a6309683b
|
@ -135,7 +135,7 @@ class Workflow(resource.Resource, ScopedResource):
|
|||
for param in input:
|
||||
if isinstance(param, dict):
|
||||
for k, v in param.items():
|
||||
input_list.append("%s=%s" % (k, v))
|
||||
input_list.append('%s="%s"' % (k, v))
|
||||
else:
|
||||
input_list.append(param)
|
||||
|
||||
|
|
|
@ -70,6 +70,31 @@ WF_NO_PARAMS:
|
|||
task1:
|
||||
action: std.noop
|
||||
"""
|
||||
WF_WITH_INPUT = """---
|
||||
version: '2.0'
|
||||
|
||||
WF_2_PARAMS:
|
||||
type: direct
|
||||
|
||||
input:
|
||||
- param1
|
||||
- param2: "value, param"
|
||||
tasks:
|
||||
task1:
|
||||
action: std.noop
|
||||
|
||||
|
||||
WF_3_PARAMS:
|
||||
type: direct
|
||||
|
||||
input:
|
||||
- param1
|
||||
- param2: "value"
|
||||
- param
|
||||
tasks:
|
||||
task1:
|
||||
action: std.noop
|
||||
"""
|
||||
|
||||
|
||||
class TestRestResource(base.DbTestCase):
|
||||
|
@ -121,6 +146,32 @@ class TestRestResource(base.DbTestCase):
|
|||
|
||||
self.assertDictEqual(expected_interface, wf_resource.interface)
|
||||
|
||||
def test_from_db_model_workflow_with_input(self):
|
||||
expected_input_two_params = "param1, param2=\"value, param\""
|
||||
expected_input_three_params = "param1, param2=\"value\", param"
|
||||
|
||||
workflows_list = wf_service.create_workflows(WF_WITH_INPUT)
|
||||
|
||||
self.assertEqual(2, len(workflows_list))
|
||||
|
||||
wf_two_params = workflows_list[0] \
|
||||
if workflows_list[0].name == 'WF_2_PARAMS' \
|
||||
else workflows_list[1]
|
||||
|
||||
wf_three_params = workflows_list[0] \
|
||||
if workflows_list[0].name == 'WF_3_PARAMS' \
|
||||
else workflows_list[1]
|
||||
|
||||
two_params_wf_resource = resources.Workflow.from_db_model(
|
||||
wf_two_params)
|
||||
three_params_wf_resource = resources.Workflow.from_db_model(
|
||||
wf_three_params)
|
||||
|
||||
self.assertEqual(expected_input_two_params,
|
||||
two_params_wf_resource.input)
|
||||
self.assertEqual(expected_input_three_params,
|
||||
three_params_wf_resource.input)
|
||||
|
||||
def test_from_dict(self):
|
||||
wf_ex = db_api.create_workflow_execution(WF_EXEC)
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ WF_WITH_DEFAULT_INPUT = {
|
|||
'definition': WF_DEFINITION_WITH_INPUT,
|
||||
'created_at': '1970-01-01 00:00:00',
|
||||
'updated_at': '1970-01-01 00:00:00',
|
||||
'input': 'param1, param2=2',
|
||||
'input': 'param1, param2="2"',
|
||||
'interface': {
|
||||
"input": ["param1", {"param2": 2}],
|
||||
"output": []
|
||||
|
@ -733,7 +733,7 @@ class TestWorkflowsController(base.APITest):
|
|||
def test_get_all_with_fields_input_filter(self, mock_get_db_wfs):
|
||||
expected_dict = {
|
||||
'id': '65df1f59-938f-4c17-bc2a-562524ef5e40',
|
||||
'input': 'param1, param2=2',
|
||||
'input': 'param1, param2="2"',
|
||||
'interface': {
|
||||
"output": [],
|
||||
"input": ["param1",
|
||||
|
|
Loading…
Reference in New Issue