diff --git a/mistralclient/api/v2/action_executions.py b/mistralclient/api/v2/action_executions.py index da276a3d..becb316c 100644 --- a/mistralclient/api/v2/action_executions.py +++ b/mistralclient/api/v2/action_executions.py @@ -76,7 +76,7 @@ class ActionExecutionManager(base.ResourceManager): qparams = {} - if limit: + if limit and limit > 0: qparams['limit'] = limit query_string = ("?%s" % urlparse.urlencode(list(qparams.items())) diff --git a/mistralclient/api/v2/actions.py b/mistralclient/api/v2/actions.py index 3b7a8000..20866f7d 100644 --- a/mistralclient/api/v2/actions.py +++ b/mistralclient/api/v2/actions.py @@ -74,7 +74,7 @@ class ActionManager(base.ResourceManager): if marker: qparams['marker'] = marker - if limit: + if limit and limit > 0: qparams['limit'] = limit if sort_keys: diff --git a/mistralclient/api/v2/executions.py b/mistralclient/api/v2/executions.py index 6d9fc28d..1e1bff46 100644 --- a/mistralclient/api/v2/executions.py +++ b/mistralclient/api/v2/executions.py @@ -82,7 +82,7 @@ class ExecutionManager(base.ResourceManager): if marker: qparams['marker'] = marker - if limit: + if limit and limit > 0: qparams['limit'] = limit if sort_keys: diff --git a/mistralclient/api/v2/tasks.py b/mistralclient/api/v2/tasks.py index 835a9a74..17450a0e 100644 --- a/mistralclient/api/v2/tasks.py +++ b/mistralclient/api/v2/tasks.py @@ -42,7 +42,7 @@ class TaskManager(base.ResourceManager): if marker: qparams['marker'] = marker - if limit: + if limit and limit > 0: qparams['limit'] = limit if sort_keys: diff --git a/mistralclient/api/v2/workflows.py b/mistralclient/api/v2/workflows.py index 97950913..04479591 100644 --- a/mistralclient/api/v2/workflows.py +++ b/mistralclient/api/v2/workflows.py @@ -82,7 +82,7 @@ class WorkflowManager(base.ResourceManager): if marker: qparams['marker'] = marker - if limit: + if limit and limit > 0: qparams['limit'] = limit if sort_keys: diff --git a/mistralclient/tests/unit/v2/test_action_executions.py b/mistralclient/tests/unit/v2/test_action_executions.py index a3ff25e5..3b3b233f 100644 --- a/mistralclient/tests/unit/v2/test_action_executions.py +++ b/mistralclient/tests/unit/v2/test_action_executions.py @@ -108,6 +108,20 @@ class TestActionExecutions(base.BaseClientV2Test): # Make sure that limit is passed to the server correctly. 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): url = self.TEST_URL + URL_TEMPLATE_ID % ACTION_EXEC['id'] self.requests_mock.get(url, json=ACTION_EXEC) diff --git a/mistralclient/tests/unit/v2/test_actions.py b/mistralclient/tests/unit/v2/test_actions.py index 8eb4cb3d..6c971790 100644 --- a/mistralclient/tests/unit/v2/test_actions.py +++ b/mistralclient/tests/unit/v2/test_actions.py @@ -182,6 +182,18 @@ class TestActionsV2(base.BaseClientV2Test): self.assertEqual(['created_at'], last_request.qs['sort_keys']) 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): self.requests_mock.get(self.TEST_URL + URL_TEMPLATE_NAME % 'action', json=ACTION) diff --git a/mistralclient/tests/unit/v2/test_executions.py b/mistralclient/tests/unit/v2/test_executions.py index 9722fc26..361685ef 100644 --- a/mistralclient/tests/unit/v2/test_executions.py +++ b/mistralclient/tests/unit/v2/test_executions.py @@ -195,6 +195,18 @@ class TestExecutionsV2(base.BaseClientV2Test): self.assertEqual(['created_at'], last_request.qs['sort_keys']) 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): url = self.TEST_URL + URL_TEMPLATE_ID % EXEC['id'] self.requests_mock.get(url, json=EXEC) diff --git a/mistralclient/tests/unit/v2/test_tasks.py b/mistralclient/tests/unit/v2/test_tasks.py index d2b3e08a..82ceb980 100644 --- a/mistralclient/tests/unit/v2/test_tasks.py +++ b/mistralclient/tests/unit/v2/test_tasks.py @@ -59,6 +59,18 @@ class TestTasksV2(base.BaseClientV2Test): self.tasks.list(fields=["id,name"]) 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): url = self.TEST_URL + URL_TEMPLATE_ID % TASK['id'] self.requests_mock.get(url, json=TASK) diff --git a/mistralclient/tests/unit/v2/test_workflows.py b/mistralclient/tests/unit/v2/test_workflows.py index bfeb4f0f..501bc1cb 100644 --- a/mistralclient/tests/unit/v2/test_workflows.py +++ b/mistralclient/tests/unit/v2/test_workflows.py @@ -168,6 +168,18 @@ class TestWorkflowsV2(base.BaseClientV2Test): self.assertEqual(['created_at'], last_request.qs['sort_keys']) 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): url = self.TEST_URL + URL_TEMPLATE_NAME % 'wf' self.requests_mock.get(url, json=WORKFLOW)