From 6726610f3c6df1668b72722f74beef603b510e49 Mon Sep 17 00:00:00 2001 From: Theodoros Tsioutsias Date: Sun, 11 Mar 2018 22:05:52 +0000 Subject: [PATCH] Add the scope attribute in workflow list The scope attribute was missing from the list of workflows and as a result the operator wasn't able to know if the worflow is public or private. This commit adds the scope attribute to the output of the workflow list command. Change-Id: Ib1e07f0388b90dc3c1d7b12ce54020e15fba868c Closes-Bug: #1746681 --- mistralclient/commands/v2/workflows.py | 2 ++ .../tests/functional/cli/v2/cli_tests_v2.py | 9 ++++-- .../tests/unit/v2/test_cli_workflows.py | 29 +++++++++++++------ 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/mistralclient/commands/v2/workflows.py b/mistralclient/commands/v2/workflows.py index 956b8d95..8a76d1a6 100644 --- a/mistralclient/commands/v2/workflows.py +++ b/mistralclient/commands/v2/workflows.py @@ -34,6 +34,7 @@ def format(workflow=None, lister=False): 'Project ID', 'Tags', 'Input', + 'Scope', 'Created at', 'Updated at' ) @@ -48,6 +49,7 @@ def format(workflow=None, lister=False): workflow.project_id, base.wrap(', '.join(tags)) or '', workflow.input if not lister else base.cut(workflow.input), + workflow.scope, workflow.created_at ) diff --git a/mistralclient/tests/functional/cli/v2/cli_tests_v2.py b/mistralclient/tests/functional/cli/v2/cli_tests_v2.py index 0230c83d..7e583364 100644 --- a/mistralclient/tests/functional/cli/v2/cli_tests_v2.py +++ b/mistralclient/tests/functional/cli/v2/cli_tests_v2.py @@ -43,7 +43,8 @@ class SimpleMistralCLITests(base.MistralCLIAuth): self.assertTableStruct( workflows, - ['ID', 'Name', 'Tags', 'Input', 'Created at', 'Updated at'] + ['ID', 'Name', 'Tags', 'Input', 'Scope', 'Created at', + 'Updated at'] ) def test_executions_list(self): @@ -560,7 +561,8 @@ class WorkflowCLITests(base_v2.MistralClientTestBase): self.assertTableStruct( workflows, - ['ID', 'Name', 'Tags', 'Input', 'Created at', 'Updated at'] + ['ID', 'Name', 'Tags', 'Input', 'Scope', 'Created at', + 'Updated at'] ) # We know that we have more than one workflow by default. @@ -576,7 +578,8 @@ class WorkflowCLITests(base_v2.MistralClientTestBase): self.assertTableStruct( workflows, - ['ID', 'Name', 'Tags', 'Input', 'Created at', 'Updated at'] + ['ID', 'Name', 'Tags', 'Input', 'Scope', 'Created at', + 'Updated at'] ) self.assertEqual(1, len(workflows)) diff --git a/mistralclient/tests/unit/v2/test_cli_workflows.py b/mistralclient/tests/unit/v2/test_cli_workflows.py index 61bec752..59177187 100644 --- a/mistralclient/tests/unit/v2/test_cli_workflows.py +++ b/mistralclient/tests/unit/v2/test_cli_workflows.py @@ -29,6 +29,7 @@ WORKFLOW_DICT = { 'project_id': '12345', 'tags': ['a', 'b'], 'input': 'param', + 'scope': 'private', 'created_at': '1', 'updated_at': '1' } @@ -56,13 +57,17 @@ class TestCLIWorkflowsV2(base.BaseCommandTest): result = self.call(workflow_cmd.Create, app_args=['1.txt']) self.assertEqual( - [('1-2-3-4', 'a', '', '12345', 'a, b', 'param', '1', '1')], + [('1-2-3-4', 'a', '', '12345', 'a, b', 'param', 'private', + '1', '1')], result[1] ) @mock.patch('argparse.open', create=True) def test_create_public(self, mock_open): - self.client.workflows.create.return_value = [WORKFLOW] + wf_public_dict = WORKFLOW_DICT.copy() + wf_public_dict['scope'] = 'public' + workflow_public = workflows.Workflow(mock, wf_public_dict) + self.client.workflows.create.return_value = [workflow_public] result = self.call( workflow_cmd.Create, @@ -70,7 +75,8 @@ class TestCLIWorkflowsV2(base.BaseCommandTest): ) self.assertEqual( - [('1-2-3-4', 'a', '', '12345', 'a, b', 'param', '1', '1')], + [('1-2-3-4', 'a', '', '12345', 'a, b', 'param', 'public', + '1', '1')], result[1] ) @@ -93,7 +99,7 @@ class TestCLIWorkflowsV2(base.BaseCommandTest): self.assertEqual( [('1-2-3-4', 'a', '', '12345', 'a, b', cmd_base.cut(long_input), - '1', '1')], + 'private', '1', '1')], result[1] ) @@ -104,7 +110,8 @@ class TestCLIWorkflowsV2(base.BaseCommandTest): result = self.call(workflow_cmd.Update, app_args=['1.txt']) self.assertEqual( - [('1-2-3-4', 'a', '', '12345', 'a, b', 'param', '1', '1')], + [('1-2-3-4', 'a', '', '12345', 'a, b', 'param', 'private', + '1', '1')], result[1] ) @@ -118,7 +125,8 @@ class TestCLIWorkflowsV2(base.BaseCommandTest): ) self.assertEqual( - [('1-2-3-4', 'a', '', '12345', 'a, b', 'param', '1', '1')], + [('1-2-3-4', 'a', '', '12345', 'a, b', 'param', 'private', + '1', '1')], result[1] ) @@ -137,7 +145,8 @@ class TestCLIWorkflowsV2(base.BaseCommandTest): ) self.assertEqual( - [('1-2-3-4', 'a', '', '12345', 'a, b', 'param', '1', '1')], + [('1-2-3-4', 'a', '', '12345', 'a, b', 'param', 'private', + '1', '1')], result[1] ) @@ -147,7 +156,8 @@ class TestCLIWorkflowsV2(base.BaseCommandTest): result = self.call(workflow_cmd.List) self.assertEqual( - [('1-2-3-4', 'a', '', '12345', 'a, b', 'param', '1', '1')], + [('1-2-3-4', 'a', '', '12345', 'a, b', 'param', 'private', + '1', '1')], result[1] ) @@ -157,7 +167,8 @@ class TestCLIWorkflowsV2(base.BaseCommandTest): result = self.call(workflow_cmd.Get, app_args=['name']) self.assertEqual( - ('1-2-3-4', 'a', '', '12345', 'a, b', 'param', '1', '1'), + ('1-2-3-4', 'a', '', '12345', 'a, b', 'param', 'private', + '1', '1'), result[1] )