Merge "Remove dates from QuotationManger list"

This commit is contained in:
Jenkins 2017-07-13 03:45:46 +00:00 committed by Gerrit Code Review
commit cd73c9ad94
2 changed files with 7 additions and 15 deletions

View File

@ -33,14 +33,11 @@ class QuotationsTest(utils.TestCase):
@mock.patch.object(base.Manager, '_list')
def test_list_with_project_id(self, mock_list):
self.client.quotations.list('2017-1-1', '2018-2-1',
'project_id')
mock_list.assert_called_with('/v2/quotations?start=2017-1-1'
'&end=2018-2-1&project_id=project_id',
self.client.quotations.list('project_id')
mock_list.assert_called_with('/v2/quotations?project_id=project_id',
'quotations')
@mock.patch.object(base.Manager, '_list')
def test_list_without_project_id(self, mock_list):
self.client.quotations.list('2017-1-1', '2018-2-1')
mock_list.assert_called_with('/v2/quotations?start=2017-1-1'
'&end=2018-2-1', 'quotations')
self.client.quotations.list()
mock_list.assert_called_with('/v2/quotations', 'quotations')

View File

@ -17,20 +17,15 @@ from distilclient import base
class QuotationManager(base.Manager):
def list(self, start, end, project_id=None):
def list(self, project_id=None):
"""Retrieve a list of quotations.
:param start: Start date of the query
:param end: End date of the query
:param project_id: Project ID, there there is no project id given,
Distil will use the project ID from token.
:returns: A list of quotations.
"""
url = "/v2/quotations?start={0}&end={1}"
url = "/v2/quotations"
if project_id:
url = url.format(start, end) + "&project_id=" + project_id
else:
url = url.format(start, end)
url = url + "?project_id=" + project_id
return self._list(url, "quotations")