diff --git a/mistralclient/tests/functional/cli/v2/cli_tests_v2.py b/mistralclient/tests/functional/cli/v2/cli_tests_v2.py index 1a51537e..80d418c9 100644 --- a/mistralclient/tests/functional/cli/v2/cli_tests_v2.py +++ b/mistralclient/tests/functional/cli/v2/cli_tests_v2.py @@ -32,22 +32,23 @@ class SimpleMistralCLITests(base.MistralCLIAuth): def test_workbooks_list(self): workbooks = self.parser.listing(self.mistral('workbook-list')) + self.assertTableStruct( workbooks, ['Name', 'Tags', 'Created at', 'Updated at'] ) def test_workflow_list(self): - workflows = self.parser.listing( - self.mistral('workflow-list')) + workflows = self.parser.listing(self.mistral('workflow-list')) + self.assertTableStruct( workflows, ['ID', 'Name', 'Tags', 'Input', 'Created at', 'Updated at'] ) def test_executions_list(self): - executions = self.parser.listing( - self.mistral('execution-list')) + executions = self.parser.listing(self.mistral('execution-list')) + self.assertTableStruct( executions, ['ID', 'Workflow name', 'Workflow ID', 'State', 'Created at', @@ -55,16 +56,16 @@ class SimpleMistralCLITests(base.MistralCLIAuth): ) def test_tasks_list(self): - tasks = self.parser.listing( - self.mistral('task-list')) + tasks = self.parser.listing(self.mistral('task-list')) + self.assertTableStruct( tasks, ['ID', 'Name', 'Workflow name', 'Execution ID', 'State'] ) def test_cron_trigger_list(self): - triggers = self.parser.listing( - self.mistral('cron-trigger-list')) + triggers = self.parser.listing(self.mistral('cron-trigger-list')) + self.assertTableStruct( triggers, ['Name', 'Workflow', 'Pattern', 'Next execution time', @@ -72,8 +73,8 @@ class SimpleMistralCLITests(base.MistralCLIAuth): ) def test_actions_list(self): - actions = self.parser.listing( - self.mistral('action-list')) + actions = self.parser.listing(self.mistral('action-list')) + self.assertTableStruct( actions, ['Name', 'Is system', 'Input', 'Description', @@ -81,16 +82,16 @@ class SimpleMistralCLITests(base.MistralCLIAuth): ) def test_environments_list(self): - envs = self.parser.listing( - self.mistral('environment-list')) + envs = self.parser.listing(self.mistral('environment-list')) + self.assertTableStruct( envs, ['Name', 'Description', 'Scope', 'Created at', 'Updated at'] ) def test_action_execution_list(self): - act_execs = self.parser.listing( - self.mistral('action-execution-list')) + act_execs = self.parser.listing(self.mistral('action-execution-list')) + self.assertTableStruct( act_execs, ['ID', 'Name', 'Workflow name', 'State', 'Accepted'] @@ -105,39 +106,40 @@ class WorkbookCLITests(base_v2.MistralClientTestBase): super(WorkbookCLITests, cls).setUpClass() def test_workbook_create_delete(self): - wb = self.mistral_admin( - 'workbook-create', params=self.wb_def) + wb = self.mistral_admin('workbook-create', params=self.wb_def) + wb_name = self.get_field_value(wb, "Name") self.assertTableStruct(wb, ['Field', 'Value']) wbs = self.mistral_admin('workbook-list') - self.assertIn(wb_name, [workbook['Name'] for workbook in wbs]) + self.assertIn(wb_name, [w['Name'] for w in wbs]) wbs = self.mistral_admin('workbook-list') - self.assertIn(wb_name, [workbook['Name'] for workbook in wbs]) + self.assertIn(wb_name, [w['Name'] for w in wbs]) self.mistral_admin('workbook-delete', params=wb_name) wbs = self.mistral_admin('workbook-list') - self.assertNotIn(wb_name, [workbook['Name'] for workbook in wbs]) + self.assertNotIn(wb_name, [w['Name'] for w in wbs]) def test_workbook_create_with_tags(self): wb = self.workbook_create(self.wb_with_tags_def) - tags = self.get_field_value(wb, 'Tags') - self.assertIn('tag', tags) + self.assertIn('tag', self.get_field_value(wb, 'Tags')) def test_workbook_update(self): wb = self.workbook_create(self.wb_def) + wb_name = self.get_field_value(wb, "Name") init_update_at = self.get_field_value(wb, "Updated at") tags = self.get_field_value(wb, 'Tags') + self.assertNotIn('tag', tags) - wb = self.mistral_admin( - 'workbook-update', params=self.wb_def) + wb = self.mistral_admin('workbook-update', params=self.wb_def) + update_at = self.get_field_value(wb, "Updated at") name = self.get_field_value(wb, 'Name') tags = self.get_field_value(wb, 'Tags') @@ -147,7 +149,10 @@ class WorkbookCLITests(base_v2.MistralClientTestBase): self.assertEqual(init_update_at, update_at) wb = self.mistral_admin( - 'workbook-update', params=self.wb_with_tags_def) + 'workbook-update', + params=self.wb_with_tags_def + ) + self.assertTableStruct(wb, ['Field', 'Value']) update_at = self.get_field_value(wb, "Updated at") @@ -160,6 +165,7 @@ class WorkbookCLITests(base_v2.MistralClientTestBase): def test_workbook_get(self): created = self.workbook_create(self.wb_with_tags_def) + wb_name = self.get_field_value(created, "Name") fetched = self.mistral_admin('workbook-get', params=wb_name) @@ -176,15 +182,19 @@ class WorkbookCLITests(base_v2.MistralClientTestBase): def test_workbook_get_definition(self): wb = self.workbook_create(self.wb_def) + wb_name = self.get_field_value(wb, "Name") definition = self.mistral_admin( - 'workbook-get-definition', params=wb_name) + 'workbook-get-definition', + params=wb_name + ) + self.assertNotIn('404 Not Found', definition) def test_workbook_validate_with_valid_def(self): - wb = self.mistral_admin( - 'workbook-validate', params=self.wb_def) + wb = self.mistral_admin('workbook-validate', params=self.wb_def) + wb_valid = self.get_field_value(wb, 'Valid') wb_error = self.get_field_value(wb, 'Error') @@ -192,10 +202,9 @@ class WorkbookCLITests(base_v2.MistralClientTestBase): self.assertEqual('None', wb_error) def test_workbook_validate_with_invalid_def(self): - self.create_file('wb.yaml', - 'name: wb\n') - wb = self.mistral_admin( - 'workbook-validate', params='wb.yaml') + self.create_file('wb.yaml', 'name: wb\n') + + wb = self.mistral_admin('workbook-validate', params='wb.yaml') wb_valid = self.get_field_value(wb, 'Valid') wb_error = self.get_field_value(wb, 'Error') @@ -212,9 +221,10 @@ class WorkflowCLITests(base_v2.MistralClientTestBase): super(WorkflowCLITests, cls).setUpClass() def test_workflow_create_delete(self): - init_wfs = self.mistral_admin( - 'workflow-create', params=self.wf_def) + init_wfs = self.mistral_admin('workflow-create', params=self.wf_def) + wf_names = [wf['Name'] for wf in init_wfs] + self.assertTableStruct(init_wfs, ['Name', 'Created at', 'Updated at']) wfs = self.mistral_admin('workflow-list') @@ -230,16 +240,23 @@ class WorkflowCLITests(base_v2.MistralClientTestBase): def test_create_wf_with_tags(self): init_wfs = self.workflow_create(self.wf_def) wf_name = init_wfs[1]['Name'] - self.assertTableStruct(init_wfs, ['Name', 'Created at', - 'Updated at', 'Tags']) + + self.assertTableStruct( + init_wfs, + ['Name', 'Created at', 'Updated at', 'Tags'] + ) created_wf_info = self.get_item_info( - get_from=init_wfs, get_by='Name', value=wf_name) + get_from=init_wfs, + get_by='Name', + value=wf_name + ) self.assertEqual('tag', created_wf_info['Tags']) def test_workflow_update(self): wf = self.workflow_create(self.wf_def) + wf_name = wf[0]['Name'] wf_id = wf[0]['ID'] @@ -323,6 +340,7 @@ class WorkflowCLITests(base_v2.MistralClientTestBase): def test_workflow_update_truncate_input(self): input_value = "very_long_input_parameter_name_that_should_be_truncated" + wf_def = """ version: "2.0" workflow1: @@ -332,43 +350,56 @@ class WorkflowCLITests(base_v2.MistralClientTestBase): task1: action: std.noop """.format(input_value) + self.create_file('wf.yaml', wf_def) self.workflow_create('wf.yaml') - upd_wf = self.mistral_admin( - 'workflow-update', params='wf.yaml') - upd_wf_info = self.get_item_info( - get_from=upd_wf, get_by='Name', value='workflow1') - self.assertEqual(upd_wf_info['Input'][:-3], input_value[:25]) + updated_wf = self.mistral_admin('workflow-update', params='wf.yaml') + + updated_wf_info = self.get_item_info( + get_from=updated_wf, + get_by='Name', + value='workflow1' + ) + + self.assertEqual(updated_wf_info['Input'][:-3], input_value[:25]) def test_workflow_get(self): created = self.workflow_create(self.wf_def) + wf_name = created[0]['Name'] fetched = self.mistral_admin('workflow-get', params=wf_name) fetched_wf_name = self.get_field_value(fetched, 'Name') + self.assertEqual(wf_name, fetched_wf_name) def test_workflow_get_with_id(self): created = self.workflow_create(self.wf_def) + wf_name = created[0]['Name'] wf_id = created[0]['ID'] fetched = self.mistral_admin('workflow-get', params=wf_id) fetched_wf_name = self.get_field_value(fetched, 'Name') + self.assertEqual(wf_name, fetched_wf_name) def test_workflow_get_definition(self): wf = self.workflow_create(self.wf_def) + wf_name = wf[0]['Name'] definition = self.mistral_admin( - 'workflow-get-definition', params=wf_name) + 'workflow-get-definition', + params=wf_name + ) + self.assertNotIn('404 Not Found', definition) def test_workflow_validate_with_valid_def(self): - wf = self.mistral_admin( - 'workflow-validate', params=self.wf_def) + wf = self.mistral_admin('workflow-validate', params=self.wf_def) + wf_valid = self.get_field_value(wf, 'Valid') wf_error = self.get_field_value(wf, 'Error') @@ -376,10 +407,9 @@ class WorkflowCLITests(base_v2.MistralClientTestBase): self.assertEqual('None', wf_error) def test_workflow_validate_with_invalid_def(self): - self.create_file('wf.yaml', - 'name: wf\n') - wf = self.mistral_admin( - 'workflow-validate', params='wf.yaml') + self.create_file('wf.yaml', 'name: wf\n') + + wf = self.mistral_admin('workflow-validate', params='wf.yaml') wf_valid = self.get_field_value(wf, 'Valid') wf_error = self.get_field_value(wf, 'Error') @@ -411,7 +441,9 @@ class ExecutionCLITests(base_v2.MistralClientTestBase): 'execution-create', params='{0} -d "execution test"'.format(self.direct_wf['Name']) ) + exec_id = self.get_field_value(execution, 'ID') + self.assertTableStruct(execution, ['Field', 'Value']) wf_name = self.get_field_value(execution, 'Workflow name') @@ -425,6 +457,7 @@ class ExecutionCLITests(base_v2.MistralClientTestBase): self.assertEqual("execution test", description) execs = self.mistral_admin('execution-list') + self.assertIn(exec_id, [ex['ID'] for ex in execs]) self.assertIn(wf_name, [ex['Workflow name'] for ex in execs]) @@ -432,10 +465,13 @@ class ExecutionCLITests(base_v2.MistralClientTestBase): def test_execution_create_with_input_and_start_task(self): execution = self.execution_create( - "%s input task_name" % self.reverse_wf['Name']) + "%s input task_name" % self.reverse_wf['Name'] + ) + exec_id = self.get_field_value(execution, 'ID') result = self.wait_execution_success(exec_id) + self.assertTrue(result) def test_execution_update(self): @@ -446,9 +482,10 @@ class ExecutionCLITests(base_v2.MistralClientTestBase): self.assertEqual('RUNNING', status) - # update execution state + # Update execution state. execution = self.mistral_admin( - 'execution-update', params='{0} -s PAUSED'.format(exec_id)) + 'execution-update', + params='{0} -s PAUSED'.format(exec_id)) updated_exec_id = self.get_field_value(execution, 'ID') status = self.get_field_value(execution, 'State') @@ -456,7 +493,7 @@ class ExecutionCLITests(base_v2.MistralClientTestBase): self.assertEqual(exec_id, updated_exec_id) self.assertEqual('PAUSED', status) - # update execution description + # Update execution description. execution = self.mistral_admin( 'execution-update', params='{0} -d "execution update test"'.format(exec_id) @@ -468,6 +505,7 @@ class ExecutionCLITests(base_v2.MistralClientTestBase): def test_execution_get(self): execution = self.execution_create(self.direct_wf['Name']) + exec_id = self.get_field_value(execution, 'ID') execution = self.mistral_admin( @@ -488,16 +526,15 @@ class ExecutionCLITests(base_v2.MistralClientTestBase): exec_id = self.get_field_value(execution, 'ID') ex_input = self.mistral_admin('execution-get-input', params=exec_id) + self.assertEqual([], ex_input) def test_execution_get_output(self): execution = self.execution_create(self.direct_wf['Name']) + exec_id = self.get_field_value(execution, 'ID') - ex_output = self.mistral_admin( - 'execution-get-output', - params=exec_id - ) + ex_output = self.mistral_admin('execution-get-output', params=exec_id) self.assertEqual([], ex_output) @@ -510,10 +547,7 @@ class ExecutionCLITests(base_v2.MistralClientTestBase): self.assertIsNot(wrapping_wf_ex_id, self.get_field_value(decoy, 'ID')) - tasks = self.mistral_admin( - 'task-list', - params=wrapping_wf_ex_id - ) + tasks = self.mistral_admin('task-list', params=wrapping_wf_ex_id) wrapping_task_id = tasks[-1]['ID'] @@ -524,7 +558,9 @@ class ExecutionCLITests(base_v2.MistralClientTestBase): ) self.assertEqual(1, len(wf_execs)) + wf_exec = wf_execs[0] + self.assertEqual(wrapping_task_id, wf_exec['Task Execution ID']) def test_executions_list_with_pagination(self): @@ -612,13 +648,16 @@ class CronTriggerCLITests(base_v2.MistralClientTestBase): super(CronTriggerCLITests, self).setUp() wf = self.workflow_create(self.wf_def) + self.wf_name = wf[0]['Name'] def test_cron_trigger_create_delete(self): trigger = self.mistral_admin( 'cron-trigger-create', params=('trigger %s {} --pattern "5 * * * *" --count 5' - ' --first-time "4242-12-25 13:37"' % self.wf_name)) + ' --first-time "4242-12-25 13:37"' % self.wf_name) + ) + self.assertTableStruct(trigger, ['Field', 'Value']) tr_name = self.get_field_value(trigger, 'Name') @@ -633,34 +672,41 @@ class CronTriggerCLITests(base_v2.MistralClientTestBase): self.assertEqual("4242-12-25 13:37:00", next_time) self.assertEqual("5", remain) - trgs = self.mistral_admin('cron-trigger-list') - self.assertIn(tr_name, [tr['Name'] for tr in trgs]) - self.assertIn(wf_name, [tr['Workflow'] for tr in trgs]) + triggers = self.mistral_admin('cron-trigger-list') + + self.assertIn(tr_name, [tr['Name'] for tr in triggers]) + self.assertIn(wf_name, [tr['Workflow'] for tr in triggers]) self.mistral('cron-trigger-delete', params=tr_name) - trgs = self.mistral_admin('cron-trigger-list') - self.assertNotIn(tr_name, [tr['Name'] for tr in trgs]) + triggers = self.mistral_admin('cron-trigger-list') + + self.assertNotIn(tr_name, [tr['Name'] for tr in triggers]) def test_two_cron_triggers_for_one_wf(self): - self.cron_trigger_create( - 'trigger1', self.wf_name, '{}', "5 * * * *") - self.cron_trigger_create( - 'trigger2', self.wf_name, '{}', "15 * * * *") + self.cron_trigger_create('trigger1', self.wf_name, '{}', "5 * * * *") - trgs = self.mistral_admin('cron-trigger-list') - self.assertIn("trigger1", [tr['Name'] for tr in trgs]) - self.assertIn("trigger2", [tr['Name'] for tr in trgs]) + self.cron_trigger_create('trigger2', self.wf_name, '{}', "15 * * * *") + + triggers = self.mistral_admin('cron-trigger-list') + + self.assertIn("trigger1", [tr['Name'] for tr in triggers]) + self.assertIn("trigger2", [tr['Name'] for tr in triggers]) def test_cron_trigger_get(self): trigger = self.cron_trigger_create( - 'trigger', self.wf_name, '{}', "5 * * * *") + 'trigger', + self.wf_name, + '{}', + "5 * * * *" + ) + self.assertTableStruct(trigger, ['Field', 'Value']) - tr_name = self.get_field_value(trigger, 'Name') - fetched_tr = self.mistral_admin( - 'cron-trigger-get', params='trigger') + 'cron-trigger-get', + params='trigger' + ) self.assertTableStruct(trigger, ['Field', 'Value']) @@ -689,6 +735,7 @@ class TaskCLITests(base_v2.MistralClientTestBase): def test_task_get(self): wf_ex = self.execution_create(self.direct_wf['Name']) + wf_ex_id = self.get_field_value(wf_ex, 'ID') tasks = self.mistral_admin('task-list', params=wf_ex_id) @@ -711,19 +758,29 @@ class ActionCLITests(base_v2.MistralClientTestBase): super(ActionCLITests, cls).setUpClass() def test_action_create_delete(self): - init_acts = self.mistral_admin( - 'action-create', params=self.act_def) - self.assertTableStruct(init_acts, ['Name', 'Is system', 'Input', - 'Description', 'Tags', - 'Created at', 'Updated at']) + init_acts = self.mistral_admin('action-create', params=self.act_def) + + self.assertTableStruct( + init_acts, + [ + 'Name', 'Is system', 'Input', 'Description', 'Tags', + 'Created at', 'Updated at' + ] + ) self.assertIn('greeting', [action['Name'] for action in init_acts]) self.assertIn('farewell', [action['Name'] for action in init_acts]) action_1 = self.get_item_info( - get_from=init_acts, get_by='Name', value='greeting') + get_from=init_acts, + get_by='Name', + value='greeting' + ) action_2 = self.get_item_info( - get_from=init_acts, get_by='Name', value='farewell') + get_from=init_acts, + get_by='Name', + value='farewell' + ) self.assertEqual('', action_1['Tags']) self.assertEqual('', action_2['Tags']) @@ -735,46 +792,69 @@ class ActionCLITests(base_v2.MistralClientTestBase): self.assertEqual('None', action_2['Input']) acts = self.mistral_admin('action-list') + self.assertIn(action_1['Name'], [action['Name'] for action in acts]) self.assertIn(action_2['Name'], [action['Name'] for action in acts]) self.mistral_admin( - 'action-delete', params='{0}'.format(action_1['Name'])) + 'action-delete', + params='{0}'.format(action_1['Name']) + ) self.mistral_admin( - 'action-delete', params='{0}'.format(action_2['Name'])) + 'action-delete', + params='{0}'.format(action_2['Name']) + ) acts = self.mistral_admin('action-list') + self.assertNotIn(action_1['Name'], [action['Name'] for action in acts]) self.assertNotIn(action_2['Name'], [action['Name'] for action in acts]) def test_action_update(self): - acts = self.action_create(self.act_def) + actions = self.action_create(self.act_def) created_action = self.get_item_info( - get_from=acts, get_by='Name', value='greeting') + get_from=actions, + get_by='Name', + value='greeting' + ) - acts = self.mistral_admin('action-update', params=self.act_def) + actions = self.mistral_admin('action-update', params=self.act_def) updated_action = self.get_item_info( - get_from=acts, get_by='Name', value='greeting') + get_from=actions, + get_by='Name', + value='greeting' + ) - self.assertEqual(created_action['Created at'].split(".")[0], - updated_action['Created at']) + self.assertEqual( + created_action['Created at'].split(".")[0], + updated_action['Created at'] + ) self.assertEqual(created_action['Name'], updated_action['Name']) - self.assertEqual(created_action['Updated at'], - updated_action['Updated at']) + self.assertEqual( + created_action['Updated at'], + updated_action['Updated at'] + ) - acts = self.mistral_admin('action-update', params=self.act_tag_def) + actions = self.mistral_admin('action-update', params=self.act_tag_def) updated_action = self.get_item_info( - get_from=acts, get_by='Name', value='greeting') + get_from=actions, + get_by='Name', + value='greeting' + ) self.assertEqual('tag, tag1', updated_action['Tags']) - self.assertEqual(created_action['Created at'].split(".")[0], - updated_action['Created at']) + self.assertEqual( + created_action['Created at'].split(".")[0], + updated_action['Created at'] + ) self.assertEqual(created_action['Name'], updated_action['Name']) - self.assertNotEqual(created_action['Updated at'], - updated_action['Updated at']) + self.assertNotEqual( + created_action['Updated at'], + updated_action['Updated at'] + ) def test_action_update_with_id(self): acts = self.action_create(self.act_def) @@ -808,6 +888,7 @@ class ActionCLITests(base_v2.MistralClientTestBase): def test_action_update_truncate_input(self): input_value = "very_long_input_parameter_name_that_should_be_truncated" + act_def = """ version: "2.0" action1: @@ -815,29 +896,39 @@ class ActionCLITests(base_v2.MistralClientTestBase): - {0} base: std.noop """.format(input_value) + self.create_file('action.yaml', act_def) self.action_create('action.yaml') - upd_act = self.mistral_admin( - 'action-update', params='action.yaml') - upd_act_info = self.get_item_info( - get_from=upd_act, get_by='Name', value='action1') - self.assertEqual(upd_act_info['Input'][:-3], input_value[:25]) + updated_act = self.mistral_admin('action-update', params='action.yaml') + + updated_act_info = self.get_item_info( + get_from=updated_act, + get_by='Name', + value='action1' + ) + + self.assertEqual(updated_act_info['Input'][:-3], input_value[:25]) def test_action_get_definition(self): self.action_create(self.act_def) definition = self.mistral_admin( - 'action-get-definition', params='greeting') + 'action-get-definition', + params='greeting' + ) + self.assertNotIn('404 Not Found', definition) def test_action_get_with_id(self): created = self.action_create(self.act_def) + action_name = created[0]['Name'] action_id = created[0]['ID'] fetched = self.mistral_admin('action-get', params=action_id) fetched_action_name = self.get_field_value(fetched, 'Name') + self.assertEqual(action_name, fetched_action_name) @@ -847,36 +938,45 @@ class EnvironmentCLITests(base_v2.MistralClientTestBase): def setUp(self): super(EnvironmentCLITests, self).setUp() - self.create_file('env.yaml', - 'name: env\n' - 'description: Test env\n' - 'variables:\n' - ' var: "value"') + self.create_file( + 'env.yaml', + 'name: env\n' + 'description: Test env\n' + 'variables:\n' + ' var: "value"' + ) def test_environment_create(self): env = self.mistral_admin('environment-create', params='env.yaml') + env_name = self.get_field_value(env, 'Name') env_desc = self.get_field_value(env, 'Description') self.assertTableStruct(env, ['Field', 'Value']) envs = self.mistral_admin('environment-list') + self.assertIn(env_name, [en['Name'] for en in envs]) self.assertIn(env_desc, [en['Description'] for en in envs]) self.mistral_admin('environment-delete', params=env_name) envs = self.mistral_admin('environment-list') + self.assertNotIn(env_name, [en['Name'] for en in envs]) def test_environment_create_without_description(self): - self.create_file('env_without_des.yaml', - 'name: env\n' - 'variables:\n' - ' var: "value"') + self.create_file( + 'env_without_des.yaml', + 'name: env\n' + 'variables:\n' + ' var: "value"' + ) - env = self.mistral_admin('environment-create', - params='env_without_des.yaml') + env = self.mistral_admin( + 'environment-create', + params='env_without_des.yaml' + ) env_name = self.get_field_value(env, 'Name') env_desc = self.get_field_value(env, 'Description') @@ -884,16 +984,19 @@ class EnvironmentCLITests(base_v2.MistralClientTestBase): self.assertTableStruct(env, ['Field', 'Value']) envs = self.mistral_admin('environment-list') + self.assertIn(env_name, [en['Name'] for en in envs]) self.assertIn(env_desc, 'None') self.mistral_admin('environment-delete', params='env') envs = self.mistral_admin('environment-list') + self.assertNotIn(env_name, [en['Name'] for en in envs]) def test_environment_update(self): env = self.environment_create('env.yaml') + env_name = self.get_field_value(env, 'Name') env_desc = self.get_field_value(env, 'Description') env_created_at = self.get_field_value(env, 'Created at') @@ -902,13 +1005,16 @@ class EnvironmentCLITests(base_v2.MistralClientTestBase): self.assertIsNotNone(env_created_at) self.assertEqual('None', env_updated_at) - self.create_file('env_upd.yaml', - 'name: env\n' - 'description: Updated env\n' - 'variables:\n' - ' var: "value"') + self.create_file( + 'env_upd.yaml', + 'name: env\n' + 'description: Updated env\n' + 'variables:\n' + ' var: "value"' + ) env = self.mistral_admin('environment-update', params='env_upd.yaml') + self.assertTableStruct(env, ['Field', 'Value']) updated_env_name = self.get_field_value(env, 'Name') @@ -924,10 +1030,12 @@ class EnvironmentCLITests(base_v2.MistralClientTestBase): def test_environment_get(self): env = self.environment_create('env.yaml') + env_name = self.get_field_value(env, 'Name') env_desc = self.get_field_value(env, 'Description') env = self.mistral_admin('environment-get', params=env_name) + fetched_env_name = self.get_field_value(env, 'Name') fetched_env_desc = self.get_field_value(env, 'Description') @@ -981,6 +1089,7 @@ class ActionExecutionCLITests(base_v2.MistralClientTestBase): params="std.echo '{0}' --save-result".format( '{"output": "Hello!"}') ) + action_ex_id = self.get_field_value(action_ex, 'ID') self.assertTableStruct(action_ex, ['Field', 'Value']) @@ -1008,455 +1117,616 @@ class NegativeCLITests(base_v2.MistralClientTestBase): """This class contains negative tests.""" def test_wb_list_extra_param(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'workbook-list', - params='param') + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'workbook-list', + params='param' + ) def test_wb_get_unexist_wb(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'workbook-get', - params='wb') + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'workbook-get', + params='wb' + ) def test_wb_get_without_param(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'workbook-get') + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'workbook-get' + ) def test_wb_create_same_name(self): self.workbook_create(self.wb_def) - self.assertRaises(exceptions.CommandFailed, - self.workbook_create, - self.wb_def) + + self.assertRaises( + exceptions.CommandFailed, + self.workbook_create, + self.wb_def + ) def test_wb_create_with_wrong_path_to_definition(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'workbook_create', - 'wb') + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'workbook_create', + 'wb' + ) def test_wb_delete_unexist_wb(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'workbook-delete', - params='wb') + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'workbook-delete', + params='wb' + ) def test_wb_update_wrong_path_to_def(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'workbook-update', - params='wb') + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'workbook-update', + params='wb' + ) def test_wb_update_nonexistant_wb(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'workbook-update', - params=self.wb_with_tags_def) + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'workbook-update', + params=self.wb_with_tags_def + ) def test_wb_create_empty_def(self): self.create_file('empty') - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'workbook-create', - params='empty') + + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'workbook-create', + params='empty' + ) def test_wb_update_empty_def(self): self.create_file('empty') - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'workbook-update', - params='empty') + + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'workbook-update', + params='empty' + ) def test_wb_get_definition_unexist_wb(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'workbook-get-definition', - params='wb') + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'workbook-get-definition', + params='wb' + ) def test_wb_create_invalid_def(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'workbook-create', - params=self.wf_def) + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'workbook-create', + params=self.wf_def + ) def test_wb_update_invalid_def(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'workbook-update', - params=self.wf_def) + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'workbook-update', + params=self.wf_def + ) def test_wb_update_without_def(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'workbook-update') + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'workbook-update' + ) def test_wf_list_extra_param(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'workflow-list', - params='param') + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'workflow-list', + params='param' + ) def test_wf_get_unexist_wf(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'workflow-get', - params='wf') + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'workflow-get', + params='wf' + ) def test_wf_get_without_param(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'workflow-get') + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'workflow-get' + ) def test_wf_create_without_definition(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'workflow-create', - params='') + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'workflow-create', + params='' + ) def test_wf_create_with_wrong_path_to_definition(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'workflow-create', - params='wf') + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'workflow-create', + params='wf' + ) def test_wf_delete_unexist_wf(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'workflow-delete', - params='wf') + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'workflow-delete', + params='wf' + ) def test_wf_update_unexist_wf(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'workflow-update', - params='wf') + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'workflow-update', + params='wf' + ) def test_wf_get_definition_unexist_wf(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'workflow-get-definition', - params='wf') + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'workflow-get-definition', + params='wf' + ) def test_wf_get_definition_missed_param(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'workflow-get-definition') + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'workflow-get-definition' + ) def test_wf_create_invalid_def(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'workflow-create', - params=self.wb_def) + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'workflow-create', + params=self.wb_def + ) def test_wf_update_invalid_def(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'workflow-update', - params=self.wb_def) + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'workflow-update', + params=self.wb_def + ) def test_wf_create_empty_def(self): self.create_file('empty') - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'workflow-create', - params='empty') + + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'workflow-create', + params='empty' + ) def test_wf_update_empty_def(self): self.create_file('empty') - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'workflow-update', - params='empty') + + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'workflow-update', + params='empty' + ) def test_ex_list_extra_param(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'execution-list', - params='param') + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'execution-list', + params='param' + ) def test_ex_create_unexist_wf(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'execution-create', - params='wf') + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'execution-create', + params='wf' + ) def test_ex_create_unexist_task(self): wf = self.workflow_create(self.wf_def) - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'execution-create', - params='%s param {}' % wf[0]['Name']) + + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'execution-create', + params='%s param {}' % wf[0]['Name'] + ) def test_ex_create_with_invalid_input(self): wf = self.workflow_create(self.wf_def) - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'execution-create', - params="%s input" % wf[0]['Name']) + + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'execution-create', + params="%s input" % wf[0]['Name'] + ) def test_ex_get_nonexist_execution(self): wf = self.workflow_create(self.wf_def) - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'execution-get', - params='%s id' % wf[0]['Name']) + + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'execution-get', + params='%s id' % wf[0]['Name'] + ) def test_ex_create_without_wf_name(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'execution-create') + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'execution-create' + ) def test_ex_create_reverse_wf_without_start_task(self): wf = self.workflow_create(self.wf_def) + self.create_file('input', '{\n "farewell": "Bye"\n}\n') - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'execution-create ', - params=wf[1]['Name']) + + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'execution-create ', + params=wf[1]['Name'] + ) def test_ex_create_missed_input(self): self.create_file('empty') + wf = self.workflow_create(self.wf_def) - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'execution-create empty', - params=wf[1]['Name']) + + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'execution-create empty', + params=wf[1]['Name'] + ) def test_ex_update_both_state_and_description(self): wf = self.workflow_create(self.wf_def) execution = self.execution_create(params=wf[0]['Name']) + exec_id = self.get_field_value(execution, 'ID') - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'execution-update', - params='%s -s ERROR -d update' % exec_id) + + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'execution-update', + params='%s -s ERROR -d update' % exec_id + ) def test_ex_delete_nonexistent_execution(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'execution-delete', params='1a2b3c') + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'execution-delete', + params='1a2b3c' + ) def test_tr_create_without_pattern(self): wf = self.workflow_create(self.wf_def) - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'cron-trigger-create', - params='tr %s {}' % wf[0]['Name']) + + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'cron-trigger-create', + params='tr %s {}' % wf[0]['Name'] + ) def test_tr_create_invalid_pattern(self): wf = self.workflow_create(self.wf_def) - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'cron-trigger-create', - params='tr %s {} --pattern "q"' % wf[0]['Name']) + + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'cron-trigger-create', + params='tr %s {} --pattern "q"' % wf[0]['Name'] + ) def test_tr_create_invalid_pattern_value_out_of_range(self): wf = self.workflow_create(self.wf_def) - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'cron-trigger-create', - params='tr %s {}' - ' --pattern "80 * * * *"' % wf[0]['Name']) + + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'cron-trigger-create', + params='tr %s {} --pattern "80 * * * *"' % wf[0]['Name'] + ) def test_tr_create_nonexistent_wf(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'cron-trigger-create', - params='tr wb.wf1 {} --pattern "* * * * *"') + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'cron-trigger-create', + params='tr wb.wf1 {} --pattern "* * * * *"' + ) def test_tr_delete_nonexistant_tr(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'cron-trigger-delete', - params='tr') + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'cron-trigger-delete', + params='tr' + ) def test_tr_get_nonexistant_tr(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'cron-trigger-get', - params='tr') + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'cron-trigger-get', + params='tr' + ) def test_tr_create_invalid_count(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'cron-trigger-create', - params='tr wb.wf1 {}' - ' --pattern "* * * * *" --count q') + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'cron-trigger-create', + params='tr wb.wf1 {} --pattern "* * * * *" --count q' + ) def test_tr_create_negative_count(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'cron-trigger-create', - params='tr wb.wf1 {}' - ' --pattern "* * * * *" --count -1') + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'cron-trigger-create', + params='tr wb.wf1 {} --pattern "* * * * *" --count -1') def test_tr_create_invalid_first_date(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'cron-trigger-create', - params='tr wb.wf1 {}' - ' --pattern "* * * * *"' - ' --first-date "q"') + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'cron-trigger-create', + params='tr wb.wf1 {} --pattern "* * * * *" --first-date "q"' + ) def test_tr_create_count_only(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'cron-trigger-create', - params='tr wb.wf1 {} --count 42') + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'cron-trigger-create', + params='tr wb.wf1 {} --count 42' + ) def test_tr_create_date_and_count_without_pattern(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'cron-trigger-create', - params='tr wb.wf1 {} --count 42' - ' --first-time "4242-12-25 13:37"') + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'cron-trigger-create', + params='tr wb.wf1 {} --count 42 --first-time "4242-12-25 13:37"' + ) def test_action_get_nonexistent(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral, - 'action-get', - params='nonexist') + self.assertRaises( + exceptions.CommandFailed, + self.mistral, + 'action-get', + params='nonexist' + ) def test_action_double_creation(self): self.action_create(self.act_def) - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'action-create', - params='{0}'.format(self.act_def)) + + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'action-create', + params='{0}'.format(self.act_def) + ) def test_action_create_without_def(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'action-create', - params='') + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'action-create', + params='' + ) def test_action_create_invalid_def(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'action-create', - params='{0}'.format(self.wb_def)) + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'action-create', + params='{0}'.format(self.wb_def) + ) def test_action_delete_nonexistent_act(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'action-delete', - params='nonexist') + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'action-delete', + params='nonexist' + ) def test_action_delete_standard_action(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'action-delete', - params='heat.events_get') + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'action-delete', + params='heat.events_get' + ) def test_action_get_definition_nonexistent_action(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'action-get-definition', - params='nonexist') + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'action-get-definition', + params='nonexist' + ) def test_task_get_nonexistent_task(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'task-get', - params='nonexist') + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'task-get', + params='nonexist' + ) def test_env_get_without_param(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'environment-get') + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'environment-get' + ) def test_env_get_nonexistent(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'environment-get', - params='nonexist') + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'environment-get', + params='nonexist' + ) def test_env_create_same_name(self): - self.create_file('env.yaml', - 'name: env\n' - 'description: Test env\n' - 'variables:\n' - ' var: "value"') + self.create_file( + 'env.yaml', + 'name: env\n' + 'description: Test env\n' + 'variables:\n' + ' var: "value"' + ) self.environment_create('env.yaml') - self.assertRaises(exceptions.CommandFailed, - self.environment_create, - 'env.yaml') + + self.assertRaises( + exceptions.CommandFailed, + self.environment_create, + 'env.yaml' + ) def test_env_create_empty(self): self.create_file('env.yaml') - self.assertRaises(exceptions.CommandFailed, - self.environment_create, - 'env.yaml') + + self.assertRaises( + exceptions.CommandFailed, + self.environment_create, + 'env.yaml' + ) def test_env_create_with_wrong_path_to_definition(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'execution_create', - 'env') + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'execution_create', + 'env' + ) def test_env_delete_unexist_env(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'environment-delete', - params='env') + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'environment-delete', + params='env' + ) def test_env_update_wrong_path_to_def(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'environment-update', - params='env') + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'environment-update', + params='env' + ) def test_env_update_empty(self): self.create_file('env.yaml') - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'environment-update', - params='env') + + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'environment-update', + params='env' + ) def test_env_update_nonexistant_env(self): - self.create_file('env.yaml', - 'name: env' - 'variables:\n var: "value"') - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'environment-update', - params='env.yaml') + self.create_file( + 'env.yaml', + 'name: env' + 'variables:\n var: "value"' + ) + + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'environment-update', + params='env.yaml' + ) def test_env_create_without_name(self): - self.create_file('env.yaml', - 'variables:\n var: "value"') - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'environment-create', - params='env.yaml') + self.create_file('env.yaml', 'variables:\n var: "value"') + + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'environment-create', + params='env.yaml' + ) def test_env_create_without_variables(self): - self.create_file('env.yaml', - 'name: env') - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'environment-create', - params='env.yaml') + self.create_file('env.yaml', 'name: env') + + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'environment-create', + params='env.yaml' + ) def test_action_execution_get_without_params(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'action-execution-get') + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'action-execution-get' + ) def test_action_execution_get_unexistent_obj(self): - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'action-execution-get', - params='123456') + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'action-execution-get', + params='123456' + ) def test_action_execution_update(self): wfs = self.workflow_create(self.wf_def) direct_wf_exec = self.execution_create(wfs[0]['Name']) + direct_ex_id = self.get_field_value(direct_wf_exec, 'ID') - self.assertRaises(exceptions.CommandFailed, - self.mistral_admin, - 'action-execution-update', - params='%s ERROR' % direct_ex_id) + self.assertRaises( + exceptions.CommandFailed, + self.mistral_admin, + 'action-execution-update', + params='%s ERROR' % direct_ex_id + )