summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gitlab/__init__.py7
-rw-r--r--gitlab/tests/test_gitlab.py9
2 files changed, 9 insertions, 7 deletions
diff --git a/gitlab/__init__.py b/gitlab/__init__.py
index f03a356..bc11071 100644
--- a/gitlab/__init__.py
+++ b/gitlab/__init__.py
@@ -343,14 +343,17 @@ class Gitlab(object):
# through normal path
cls_kwargs['_created'] = True
+ get_all_results = params.get('all', False)
+
# Remove parameters from kwargs before passing it to constructor
- for key in ['page', 'per_page', 'sudo']:
+ for key in ['all', 'page', 'per_page', 'sudo']:
if key in cls_kwargs:
del cls_kwargs[key]
results = [cls(self, item, **cls_kwargs) for item in r.json()
if item is not None]
- if 'next' in r.links and 'url' in r.links['next']:
+ if ('next' in r.links and 'url' in r.links['next']
+ and get_all_results is True):
args = kwargs.copy()
args['next_url'] = r.links['next']['url']
results.extend(self.list(obj_class, **args))
diff --git a/gitlab/tests/test_gitlab.py b/gitlab/tests/test_gitlab.py
index 0743435..60cb94e 100644
--- a/gitlab/tests/test_gitlab.py
+++ b/gitlab/tests/test_gitlab.py
@@ -180,8 +180,7 @@ class TestGitLabMethods(unittest.TestCase):
def test_list_next_link(self):
@urlmatch(scheme="http", netloc="localhost",
- path='/api/v3/projects/1/repository/branches', method="get",
- query=r'per_page=1')
+ path='/api/v3/projects/1/repository/branches', method="get")
def resp_one(url, request):
"""First request:
@@ -217,9 +216,9 @@ class TestGitLabMethods(unittest.TestCase):
resp = response(200, content, headers, None, 5, request)
return resp
- with HTTMock(resp_one, resp_two):
- data = self.gl.list(ProjectBranch, project_id=1,
- per_page=1)
+ with HTTMock(resp_two, resp_one):
+ data = self.gl.list(ProjectBranch, project_id=1, per_page=1,
+ all=True)
self.assertEqual(data[1].branch_name, "testbranch")
self.assertEqual(data[1].project_id, 1)
self.assertEqual(data[1].ref, "a")