Merge "Add task_execution_id to workflow execution in CLI"

This commit is contained in:
Jenkins 2016-02-01 08:20:38 +00:00 committed by Gerrit Code Review
commit 9883b2ac1a
3 changed files with 96 additions and 31 deletions

View File

@ -37,6 +37,7 @@ def format(execution=None, lister=False):
'ID',
'Workflow',
'Description',
'Task Execution ID',
'State',
'State info',
'Created at',
@ -52,6 +53,7 @@ def format(execution=None, lister=False):
execution.id,
execution.workflow_name,
execution.description,
execution.task_execution_id or '<none>',
execution.state,
state_info,
execution.created_at,

View File

@ -22,20 +22,41 @@ from mistralclient.api.v2 import executions
from mistralclient.commands.v2 import executions as execution_cmd
from mistralclient.tests.unit import base
EXECUTION = executions.Execution(mock, {
'id': '123',
'workflow_name': 'some',
'description': '',
'state': 'RUNNING',
'state_info': None,
'created_at': '1',
'updated_at': '1'
})
EXEC = executions.Execution(
mock,
{
'id': '123',
'workflow_name': 'some',
'description': '',
'state': 'RUNNING',
'state_info': None,
'created_at': '1',
'updated_at': '1',
'task_execution_id': None
}
)
SUB_WF_EXEC = executions.Execution(
mock,
{
'id': '456',
'workflow_name': 'some_sub_wf',
'description': '',
'state': 'RUNNING',
'state_info': None,
'created_at': '1',
'updated_at': '1',
'task_execution_id': 'abc'
}
)
EX_RESULT = ('123', 'some', '', '<none>', 'RUNNING', None, '1', '1')
SUB_WF_EX_RESULT = ('456', 'some_sub_wf', '', 'abc', 'RUNNING', None, '1', '1')
class TestCLIExecutionsV2(base.BaseCommandTest):
def test_create_wf_input_string(self):
self.client.executions.create.return_value = EXECUTION
self.client.executions.create.return_value = EXEC
result = self.call(
execution_cmd.Create,
@ -43,12 +64,12 @@ class TestCLIExecutionsV2(base.BaseCommandTest):
)
self.assertEqual(
('123', 'some', '', 'RUNNING', None, '1', '1'),
EX_RESULT,
result[1]
)
def test_create_wf_input_file(self):
self.client.executions.create.return_value = EXECUTION
self.client.executions.create.return_value = EXEC
path = pkg.resource_filename(
'mistralclient',
@ -61,12 +82,12 @@ class TestCLIExecutionsV2(base.BaseCommandTest):
)
self.assertEqual(
('123', 'some', '', 'RUNNING', None, '1', '1'),
EX_RESULT,
result[1]
)
def test_create_with_description(self):
self.client.executions.create.return_value = EXECUTION
self.client.executions.create.return_value = EXEC
result = self.call(
execution_cmd.Create,
@ -74,12 +95,12 @@ class TestCLIExecutionsV2(base.BaseCommandTest):
)
self.assertEqual(
('123', 'some', '', 'RUNNING', None, '1', '1'),
EX_RESULT,
result[1]
)
def test_update_state(self):
self.client.executions.update.return_value = EXECUTION
self.client.executions.update.return_value = EXEC
result = self.call(
execution_cmd.Update,
@ -87,12 +108,12 @@ class TestCLIExecutionsV2(base.BaseCommandTest):
)
self.assertEqual(
('123', 'some', '', 'RUNNING', None, '1', '1'),
EX_RESULT,
result[1]
)
def test_resume_update_env(self):
self.client.executions.update.return_value = EXECUTION
self.client.executions.update.return_value = EXEC
result = self.call(
execution_cmd.Update,
@ -100,12 +121,12 @@ class TestCLIExecutionsV2(base.BaseCommandTest):
)
self.assertEqual(
('123', 'some', '', 'RUNNING', None, '1', '1'),
EX_RESULT,
result[1]
)
def test_update_description(self):
self.client.executions.update.return_value = EXECUTION
self.client.executions.update.return_value = EXEC
result = self.call(
execution_cmd.Update,
@ -113,22 +134,22 @@ class TestCLIExecutionsV2(base.BaseCommandTest):
)
self.assertEqual(
('123', 'some', '', 'RUNNING', None, '1', '1'),
EX_RESULT,
result[1]
)
def test_list(self):
self.client.executions.list.return_value = (EXECUTION,)
self.client.executions.list.return_value = (EXEC, SUB_WF_EXEC)
result = self.call(execution_cmd.List)
self.assertEqual(
[('123', 'some', '', 'RUNNING', None, '1', '1')],
[EX_RESULT, SUB_WF_EX_RESULT],
result[1]
)
def test_list_with_pagination(self):
self.client.executions.list.return_value = (EXECUTION,)
self.client.executions.list.return_value = (EXEC,)
self.call(execution_cmd.List)
self.client.executions.list.assert_called_once_with(
@ -156,12 +177,22 @@ class TestCLIExecutionsV2(base.BaseCommandTest):
)
def test_get(self):
self.client.executions.get.return_value = EXECUTION
self.client.executions.get.return_value = EXEC
result = self.call(execution_cmd.Get, app_args=['id'])
self.assertEqual(
('123', 'some', '', 'RUNNING', None, '1', '1'),
EX_RESULT,
result[1]
)
def test_get_sub_wf_ex(self):
self.client.executions.get.return_value = SUB_WF_EXEC
result = self.call(execution_cmd.Get, app_args=['id'])
self.assertEqual(
SUB_WF_EX_RESULT,
result[1]
)

View File

@ -35,6 +35,19 @@ EXEC = {
}
}
SUB_WF_EXEC = {
'id': "456",
'workflow_name': 'my_sub_wf',
'task_execution_id': "abc",
'description': '',
'state': 'RUNNING',
'input': {
"person": {
"first_name": "John",
"last_name": "Doe"
}
}
}
URL_TEMPLATE = '/executions'
URL_TEMPLATE_ID = '/executions/%s'
@ -124,15 +137,22 @@ class TestExecutionsV2(base.BaseClientV2Test):
)
def test_list(self):
mock = self.mock_http_get(content={'executions': [EXEC]})
mock = self.mock_http_get(content={'executions': [EXEC, SUB_WF_EXEC]})
execution_list = self.executions.list()
self.assertEqual(1, len(execution_list))
ex = execution_list[0]
self.assertEqual(2, len(execution_list))
self.assertEqual(
executions.Execution(self.executions, EXEC).to_dict(),
execution_list[0].to_dict()
)
self.assertEqual(
executions.Execution(self.executions, SUB_WF_EXEC).to_dict(),
execution_list[1].to_dict()
)
self.assertEqual(executions.Execution(self.executions, EXEC).to_dict(),
ex.to_dict())
mock.assert_called_once_with(URL_TEMPLATE)
def test_list_with_pagination(self):
@ -165,6 +185,18 @@ class TestExecutionsV2(base.BaseClientV2Test):
mock.assert_called_once_with(URL_TEMPLATE_ID % EXEC['id'])
def test_get_sub_wf_ex(self):
mock = self.mock_http_get(content=SUB_WF_EXEC)
ex = self.executions.get(SUB_WF_EXEC['id'])
self.assertEqual(
executions.Execution(self.executions, SUB_WF_EXEC).to_dict(),
ex.to_dict()
)
mock.assert_called_once_with(URL_TEMPLATE_ID % SUB_WF_EXEC['id'])
def test_delete(self):
mock = self.mock_http_delete(status_code=204)