Remove dates from QuotationManger list

Quotations are always returned for the current month, distil
doesn't take request parameters into account for it. This changes
the manager to adhere to that.

Change-Id: I2bbc6e1033e97370c88396c42d92fbd828592eed
This commit is contained in:
Amelia Cordwell 2017-07-05 13:39:22 +12:00
parent 33226737b0
commit 0e11ec52e7
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")