Skip to content

Commit c08c913

Browse files
author
Gauvain Pocentek
committed
Fix and test pagination
Fixes #140
1 parent 29e2efe commit c08c913

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

gitlab/__init__.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -365,14 +365,14 @@ def _raw_list(self, path, cls, extra_attrs={}, **kwargs):
365365

366366
get_all_results = kwargs.get('all', False)
367367

368+
r = self._raw_get(path, **params)
369+
raise_error_from_response(r, GitlabListError)
370+
368371
# Remove parameters from kwargs before passing it to constructor
369372
for key in ['all', 'page', 'per_page', 'sudo', 'next_url']:
370373
if key in params:
371374
del params[key]
372375

373-
r = self._raw_get(path, **params)
374-
raise_error_from_response(r, GitlabListError)
375-
376376
# Add _from_api manually, because we are not creating objects
377377
# through normal path
378378
params['_from_api'] = True

tools/python_test.py

+7
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,13 @@
136136
assert(len(gl.projects.owned()) == 2)
137137
assert(len(gl.projects.search("admin")) == 1)
138138

139+
# test pagination
140+
l1 = gl.projects.list(per_page=1, page=1)
141+
l2 = gl.projects.list(per_page=1, page=2)
142+
assert(len(l1) == 1)
143+
assert(len(l2) == 1)
144+
assert(l1[0].id != l2[0].id)
145+
139146
# project content (files)
140147
admin_project.files.create({'file_path': 'README',
141148
'branch_name': 'master',

0 commit comments

Comments
 (0)