Merge "Align filter params for deployment history command" into stable/mitaka

This commit is contained in:
Jenkins
2016-09-05 12:38:09 +00:00
committed by Gerrit Code Review
3 changed files with 11 additions and 18 deletions

View File

@@ -95,9 +95,7 @@ class TestDeploymentTasksAction(base.UnitTestCase):
def test_show_history_for_special_nodes(self):
self.m_history_api = self.m_request.get(
'/api/v1/transactions/1/deployment_history/?'
'nodes=1,2&'
'statuses=&'
'tasks_names=',
'nodes=1,2',
json={})
self.execute(
@@ -110,8 +108,6 @@ class TestDeploymentTasksAction(base.UnitTestCase):
def test_show_history_for_special_tasks(self):
self.m_history_api = self.m_request.get(
'/api/v1/transactions/1/deployment_history/?'
'nodes=&'
'statuses=&'
'tasks_names=test1,test2',
json={})
@@ -125,9 +121,7 @@ class TestDeploymentTasksAction(base.UnitTestCase):
def test_show_history_with_special_statuses(self):
self.m_history_api = self.m_request.get(
'/api/v1/transactions/1/deployment_history/?'
'nodes=&'
'statuses=ready,skipped&'
'tasks_names=',
'statuses=ready,skipped',
json={})
self.execute(
['fuel', 'deployment-tasks', '--tid', '1',

View File

@@ -35,9 +35,8 @@ class TestDeploymentHistoryFacade(test_api.BaseLibTest):
self.client = fuelclient.get_client('deployment_history', self.version)
def get_url(self, nodes='', statuses='', tasks_names=''):
return self.res_uri + '?nodes={}&statuses={}&tasks_names={}'.format(
nodes, statuses, tasks_names
)
params = '?nodes={}&statuses={}&tasks_names={}'
return self.res_uri + params.format(nodes, statuses, tasks_names)
def test_deployment_history_list(self):

View File

@@ -23,9 +23,7 @@ from fuelclient.v1 import base_v1
class DeploymentHistoryClient(base_v1.BaseV1Client):
class_api_path = "transactions/{transaction_id}/deployment_history/" \
"?nodes={nodes}&statuses={statuses}" \
"&tasks_names={tasks_names}"
class_api_path = "transactions/{transaction_id}/deployment_history/"
history_records_keys = ("task_name", "node_id", "status",
"time_start", "time_end")
@@ -40,15 +38,17 @@ class DeploymentHistoryClient(base_v1.BaseV1Client):
'nodes': nodes,
'tasks_names': tasks_names
}
# remove unused parameters or parameters with empty list as value
parameters = {k: v for k, v in six.iteritems(parameters)
if v is not None and v}
# 'parameters': ['param1', 'param2'] --> 'parameters': 'param1,param2'
for k in parameters:
parameters[k] = ",".join(str(s) for s in parameters[k]) \
if parameters[k] else ""
parameters[k] = ",".join(s for s in parameters[k])
history_with_tasks = APIClient.get_request(
self.class_api_path.format(
transaction_id=transaction_id,
**parameters
)
), params=parameters
)
# rename legacy field for Fuel 9.0
for record in history_with_tasks: