Align filter params for deployment history command

After the commit c179e5d0b4b8a5b4566120eceb81a1d0ed9577c8
GET request to Nailgun should not contain parameters
with empty values, e.g. /?param=&param1=&param2.
This patch aligns 'fuel2 task history show' command
execution removing empty parameters from GET requet

Change-Id: I04f02767c45691dc4345bd73d1cc3fb3d7bd4852
Closes-Bug: 1610177
(cherry picked from commit ec2ed50acb)
This commit is contained in:
tivaliy 2016-08-15 21:40:39 +03:00 committed by Alexey Shtokolov
parent d13f0c5178
commit 908ca5cc6b
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: