summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvain@pocentek.net>2016-09-03 18:35:21 +0200
committerGauvain Pocentek <gauvain@pocentek.net>2016-09-03 18:39:07 +0200
commitc08c913b82bf7421600b248d055db497d627802a (patch)
tree4215bc66bc490970e39d1755b3b541876598f128
parent29e2efeae22ce5fa82e3541360b234e0053a65c2 (diff)
downloadgitlab-c08c913b82bf7421600b248d055db497d627802a.tar.gz
Fix and test pagination
Fixes #140
-rw-r--r--gitlab/__init__.py6
-rw-r--r--tools/python_test.py7
2 files changed, 10 insertions, 3 deletions
diff --git a/gitlab/__init__.py b/gitlab/__init__.py
index 5f72d0d..cbe90e3 100644
--- a/gitlab/__init__.py
+++ b/gitlab/__init__.py
@@ -365,14 +365,14 @@ class Gitlab(object):
get_all_results = kwargs.get('all', False)
+ r = self._raw_get(path, **params)
+ raise_error_from_response(r, GitlabListError)
+
# Remove parameters from kwargs before passing it to constructor
for key in ['all', 'page', 'per_page', 'sudo', 'next_url']:
if key in params:
del params[key]
- r = self._raw_get(path, **params)
- raise_error_from_response(r, GitlabListError)
-
# Add _from_api manually, because we are not creating objects
# through normal path
params['_from_api'] = True
diff --git a/tools/python_test.py b/tools/python_test.py
index 9204862..f9f5bb8 100644
--- a/tools/python_test.py
+++ b/tools/python_test.py
@@ -136,6 +136,13 @@ assert(len(gl.projects.all()) == 4)
assert(len(gl.projects.owned()) == 2)
assert(len(gl.projects.search("admin")) == 1)
+# test pagination
+l1 = gl.projects.list(per_page=1, page=1)
+l2 = gl.projects.list(per_page=1, page=2)
+assert(len(l1) == 1)
+assert(len(l2) == 1)
+assert(l1[0].id != l2[0].id)
+
# project content (files)
admin_project.files.create({'file_path': 'README',
'branch_name': 'master',