Merge "Fix limit handling to not send value of -1"
This commit is contained in:
commit
02985bb30e
@ -76,7 +76,7 @@ class ActionExecutionManager(base.ResourceManager):
|
|||||||
|
|
||||||
qparams = {}
|
qparams = {}
|
||||||
|
|
||||||
if limit:
|
if limit and limit > 0:
|
||||||
qparams['limit'] = limit
|
qparams['limit'] = limit
|
||||||
|
|
||||||
query_string = ("?%s" % urlparse.urlencode(list(qparams.items()))
|
query_string = ("?%s" % urlparse.urlencode(list(qparams.items()))
|
||||||
|
@ -74,7 +74,7 @@ class ActionManager(base.ResourceManager):
|
|||||||
if marker:
|
if marker:
|
||||||
qparams['marker'] = marker
|
qparams['marker'] = marker
|
||||||
|
|
||||||
if limit:
|
if limit and limit > 0:
|
||||||
qparams['limit'] = limit
|
qparams['limit'] = limit
|
||||||
|
|
||||||
if sort_keys:
|
if sort_keys:
|
||||||
|
@ -82,7 +82,7 @@ class ExecutionManager(base.ResourceManager):
|
|||||||
if marker:
|
if marker:
|
||||||
qparams['marker'] = marker
|
qparams['marker'] = marker
|
||||||
|
|
||||||
if limit:
|
if limit and limit > 0:
|
||||||
qparams['limit'] = limit
|
qparams['limit'] = limit
|
||||||
|
|
||||||
if sort_keys:
|
if sort_keys:
|
||||||
|
@ -42,7 +42,7 @@ class TaskManager(base.ResourceManager):
|
|||||||
if marker:
|
if marker:
|
||||||
qparams['marker'] = marker
|
qparams['marker'] = marker
|
||||||
|
|
||||||
if limit:
|
if limit and limit > 0:
|
||||||
qparams['limit'] = limit
|
qparams['limit'] = limit
|
||||||
|
|
||||||
if sort_keys:
|
if sort_keys:
|
||||||
|
@ -82,7 +82,7 @@ class WorkflowManager(base.ResourceManager):
|
|||||||
if marker:
|
if marker:
|
||||||
qparams['marker'] = marker
|
qparams['marker'] = marker
|
||||||
|
|
||||||
if limit:
|
if limit and limit > 0:
|
||||||
qparams['limit'] = limit
|
qparams['limit'] = limit
|
||||||
|
|
||||||
if sort_keys:
|
if sort_keys:
|
||||||
|
@ -108,6 +108,20 @@ class TestActionExecutions(base.BaseClientV2Test):
|
|||||||
# Make sure that limit is passed to the server correctly.
|
# Make sure that limit is passed to the server correctly.
|
||||||
self.assertEqual(['1'], last_request.qs['limit'])
|
self.assertEqual(['1'], last_request.qs['limit'])
|
||||||
|
|
||||||
|
def test_list_with_no_limit(self):
|
||||||
|
self.requests_mock.get(
|
||||||
|
self.TEST_URL + URL_TEMPLATE,
|
||||||
|
json={'action_executions': [ACTION_EXEC]}
|
||||||
|
)
|
||||||
|
|
||||||
|
action_execution_list = self.action_executions.list(limit=-1)
|
||||||
|
|
||||||
|
self.assertEqual(1, len(action_execution_list))
|
||||||
|
|
||||||
|
last_request = self.requests_mock.last_request
|
||||||
|
|
||||||
|
self.assertNotIn('limit', last_request.qs)
|
||||||
|
|
||||||
def test_get(self):
|
def test_get(self):
|
||||||
url = self.TEST_URL + URL_TEMPLATE_ID % ACTION_EXEC['id']
|
url = self.TEST_URL + URL_TEMPLATE_ID % ACTION_EXEC['id']
|
||||||
self.requests_mock.get(url, json=ACTION_EXEC)
|
self.requests_mock.get(url, json=ACTION_EXEC)
|
||||||
|
@ -182,6 +182,18 @@ class TestActionsV2(base.BaseClientV2Test):
|
|||||||
self.assertEqual(['created_at'], last_request.qs['sort_keys'])
|
self.assertEqual(['created_at'], last_request.qs['sort_keys'])
|
||||||
self.assertEqual(['asc'], last_request.qs['sort_dirs'])
|
self.assertEqual(['asc'], last_request.qs['sort_dirs'])
|
||||||
|
|
||||||
|
def test_list_with_no_limit(self):
|
||||||
|
self.requests_mock.get(self.TEST_URL + URL_TEMPLATE,
|
||||||
|
json={'actions': [ACTION]})
|
||||||
|
|
||||||
|
action_list = self.actions.list(limit=-1)
|
||||||
|
|
||||||
|
self.assertEqual(1, len(action_list))
|
||||||
|
|
||||||
|
last_request = self.requests_mock.last_request
|
||||||
|
|
||||||
|
self.assertNotIn('limit', last_request.qs)
|
||||||
|
|
||||||
def test_get(self):
|
def test_get(self):
|
||||||
self.requests_mock.get(self.TEST_URL + URL_TEMPLATE_NAME % 'action',
|
self.requests_mock.get(self.TEST_URL + URL_TEMPLATE_NAME % 'action',
|
||||||
json=ACTION)
|
json=ACTION)
|
||||||
|
@ -195,6 +195,18 @@ class TestExecutionsV2(base.BaseClientV2Test):
|
|||||||
self.assertEqual(['created_at'], last_request.qs['sort_keys'])
|
self.assertEqual(['created_at'], last_request.qs['sort_keys'])
|
||||||
self.assertEqual(['asc'], last_request.qs['sort_dirs'])
|
self.assertEqual(['asc'], last_request.qs['sort_dirs'])
|
||||||
|
|
||||||
|
def test_list_with_no_limit(self):
|
||||||
|
self.requests_mock.get(self.TEST_URL + URL_TEMPLATE,
|
||||||
|
json={'executions': [EXEC]})
|
||||||
|
|
||||||
|
execution_list = self.executions.list(limit=-1)
|
||||||
|
|
||||||
|
self.assertEqual(1, len(execution_list))
|
||||||
|
|
||||||
|
last_request = self.requests_mock.last_request
|
||||||
|
|
||||||
|
self.assertNotIn('limit', last_request.qs)
|
||||||
|
|
||||||
def test_get(self):
|
def test_get(self):
|
||||||
url = self.TEST_URL + URL_TEMPLATE_ID % EXEC['id']
|
url = self.TEST_URL + URL_TEMPLATE_ID % EXEC['id']
|
||||||
self.requests_mock.get(url, json=EXEC)
|
self.requests_mock.get(url, json=EXEC)
|
||||||
|
@ -59,6 +59,18 @@ class TestTasksV2(base.BaseClientV2Test):
|
|||||||
self.tasks.list(fields=["id,name"])
|
self.tasks.list(fields=["id,name"])
|
||||||
self.assertTrue(self.requests_mock.called_once)
|
self.assertTrue(self.requests_mock.called_once)
|
||||||
|
|
||||||
|
def test_list_with_no_limit(self):
|
||||||
|
self.requests_mock.get(self.TEST_URL + URL_TEMPLATE,
|
||||||
|
json={'tasks': [TASK]})
|
||||||
|
|
||||||
|
task_list = self.tasks.list(limit=-1)
|
||||||
|
|
||||||
|
self.assertEqual(1, len(task_list))
|
||||||
|
|
||||||
|
last_request = self.requests_mock.last_request
|
||||||
|
|
||||||
|
self.assertNotIn('limit', last_request.qs)
|
||||||
|
|
||||||
def test_get(self):
|
def test_get(self):
|
||||||
url = self.TEST_URL + URL_TEMPLATE_ID % TASK['id']
|
url = self.TEST_URL + URL_TEMPLATE_ID % TASK['id']
|
||||||
self.requests_mock.get(url, json=TASK)
|
self.requests_mock.get(url, json=TASK)
|
||||||
|
@ -168,6 +168,18 @@ class TestWorkflowsV2(base.BaseClientV2Test):
|
|||||||
self.assertEqual(['created_at'], last_request.qs['sort_keys'])
|
self.assertEqual(['created_at'], last_request.qs['sort_keys'])
|
||||||
self.assertEqual(['asc'], last_request.qs['sort_dirs'])
|
self.assertEqual(['asc'], last_request.qs['sort_dirs'])
|
||||||
|
|
||||||
|
def test_list_with_no_limit(self):
|
||||||
|
self.requests_mock.get(self.TEST_URL + URL_TEMPLATE,
|
||||||
|
json={'workflows': [WORKFLOW]})
|
||||||
|
|
||||||
|
workflows_list = self.workflows.list(limit=-1)
|
||||||
|
|
||||||
|
self.assertEqual(1, len(workflows_list))
|
||||||
|
|
||||||
|
last_request = self.requests_mock.last_request
|
||||||
|
|
||||||
|
self.assertNotIn('limit', last_request.qs)
|
||||||
|
|
||||||
def test_get(self):
|
def test_get(self):
|
||||||
url = self.TEST_URL + URL_TEMPLATE_NAME % 'wf'
|
url = self.TEST_URL + URL_TEMPLATE_NAME % 'wf'
|
||||||
self.requests_mock.get(url, json=WORKFLOW)
|
self.requests_mock.get(url, json=WORKFLOW)
|
||||||
|
Loading…
Reference in New Issue
Block a user