Fixing tasks operations in mistralclient

* Deleted PUT/update operation from lib and CLI
 * Recovered filtering tasks by workflow execution:
   mistral task-list [workflow-execution-id]

Partially implements blueprint mistral-refactor-task-output

Change-Id: I0bf975f874865bbd178120cb3f1062812f3351ac
This commit is contained in:
Nikolay Mahotkin
2015-03-20 15:57:31 +03:00
parent f07d3ee6ea
commit 1df04e7b6b
5 changed files with 23 additions and 62 deletions

View File

@@ -44,16 +44,6 @@ TASK_WITH_INPUT = tasks.Task(mock, TASK_WITH_INPUT_DICT)
class TestCLITasksV2(base.BaseCommandTest):
@mock.patch('mistralclient.api.v2.tasks.TaskManager.update')
def test_update(self, mock):
mock.return_value = TASK
result = self.call(task_cmd.Update,
app_args=['id', 'ERROR'])
self.assertEqual(('123', 'some', 'thing', '321', 'RUNNING'),
result[1])
@mock.patch('mistralclient.api.v2.tasks.TaskManager.list')
def test_list(self, mock):
mock.return_value = (TASK,)
@@ -63,6 +53,15 @@ class TestCLITasksV2(base.BaseCommandTest):
self.assertEqual([('123', 'some', 'thing', '321', 'RUNNING')],
result[1])
@mock.patch('mistralclient.api.v2.tasks.TaskManager.list')
def test_list_with_workflow_execution(self, mock):
mock.return_value = (TASK,)
result = self.call(task_cmd.List, app_args=['workflow_execution'])
self.assertEqual([('123', 'some', 'thing', '321', 'RUNNING')],
result[1])
@mock.patch('mistralclient.api.v2.tasks.TaskManager.get')
def test_get(self, mock):
mock.return_value = TASK

View File

@@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import json
from mistralclient.api.v2 import tasks
from mistralclient.tests.unit.v2 import base
@@ -25,7 +23,8 @@ TASK = {
'name': 'my_task',
'workflow_name': 'my_wf',
'state': 'RUNNING',
'tags': ['deployment', 'demo']
'tags': ['deployment', 'demo'],
'result': {'some': 'result'}
}
@@ -34,20 +33,6 @@ URL_TEMPLATE_ID = '/tasks/%s'
class TestTasksV2(base.BaseClientV2Test):
def test_update(self):
mock = self.mock_http_put(content=TASK)
body = {
'state': TASK['state']
}
task = self.tasks.update(TASK['id'],
TASK['state'])
self.assertIsNotNone(task)
self.assertEqual(tasks.Task(self.tasks, TASK).__dict__, task.__dict__)
mock.assert_called_once_with(
URL_TEMPLATE_ID % TASK['id'], json.dumps(body))
def test_list(self):
mock = self.mock_http_get(content={'tasks': [TASK]})