summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Meier <r.meier@siemens.com>2019-12-09 09:47:28 +0100
committerGitHub <noreply@github.com>2019-12-09 09:47:28 +0100
commit3e2d69417aa8c6b043ee99fea5f8d7e31a2ba3e8 (patch)
tree8d56c110efd7e3f9aa30d9dd5f38329ed8822b96
parent18913ddce18f78e7432f4d041ab4bd071e57b256 (diff)
parentb5e88f3e99e2b07e0bafe7de33a8899e97c3bb40 (diff)
downloadgitlab-3e2d69417aa8c6b043ee99fea5f8d7e31a2ba3e8.tar.gz
Merge pull request #963 from python-gitlab/fix/as_list
Fix/as list
-rw-r--r--.travis.yml2
-rw-r--r--gitlab/__init__.py2
-rw-r--r--gitlab/tests/test_gitlab.py18
-rw-r--r--gitlab/v4/objects.py8
4 files changed, 24 insertions, 6 deletions
diff --git a/.travis.yml b/.travis.yml
index 36f2961..b631f21 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -23,7 +23,7 @@ jobs:
dist: bionic
python: 3.7
script:
- - pip3 install black
+ - pip3 install -U --pre black
- black --check .
- stage: test
name: cli_func_v4
diff --git a/gitlab/__init__.py b/gitlab/__init__.py
index 883bb44..3605b80 100644
--- a/gitlab/__init__.py
+++ b/gitlab/__init__.py
@@ -630,7 +630,7 @@ class Gitlab(object):
get_all = kwargs.pop("all", False)
url = self._build_url(path)
- if get_all is True:
+ if get_all is True and as_list is True:
return list(GitlabList(self, url, query_data, **kwargs))
if "page" in kwargs or as_list is True:
diff --git a/gitlab/tests/test_gitlab.py b/gitlab/tests/test_gitlab.py
index f9d4cc8..7449b3a 100644
--- a/gitlab/tests/test_gitlab.py
+++ b/gitlab/tests/test_gitlab.py
@@ -119,6 +119,24 @@ class TestGitlabList(unittest.TestCase):
self.assertEqual(l[0]["a"], "b")
self.assertEqual(l[1]["c"], "d")
+ def test_all_omitted_when_as_list(self):
+ @urlmatch(scheme="http", netloc="localhost", path="/api/v4/tests", method="get")
+ def resp(url, request):
+ headers = {
+ "content-type": "application/json",
+ "X-Page": 2,
+ "X-Next-Page": 2,
+ "X-Per-Page": 1,
+ "X-Total-Pages": 2,
+ "X-Total": 2,
+ }
+ content = '[{"c": "d"}]'
+ return response(200, content, headers, None, 5, request)
+
+ with HTTMock(resp):
+ result = self.gl.http_list("/tests", as_list=False, all=True)
+ self.assertIsInstance(result, GitlabList)
+
class TestGitlabHttpMethods(unittest.TestCase):
def setUp(self):
diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py
index 5125ff4..89e3259 100644
--- a/gitlab/v4/objects.py
+++ b/gitlab/v4/objects.py
@@ -762,8 +762,8 @@ class GroupClusterManager(CRUDMixin, RESTManager):
_obj_cls = GroupCluster
_from_parent_attrs = {"group_id": "id"}
_create_attrs = (
- ("name", "platform_kubernetes_attributes",),
- ("domain", "enabled", "managed", "environment_scope",),
+ ("name", "platform_kubernetes_attributes"),
+ ("domain", "enabled", "managed", "environment_scope"),
)
_update_attrs = (
tuple(),
@@ -1664,8 +1664,8 @@ class ProjectClusterManager(CRUDMixin, RESTManager):
_obj_cls = ProjectCluster
_from_parent_attrs = {"project_id": "id"}
_create_attrs = (
- ("name", "platform_kubernetes_attributes",),
- ("domain", "enabled", "managed", "environment_scope",),
+ ("name", "platform_kubernetes_attributes"),
+ ("domain", "enabled", "managed", "environment_scope"),
)
_update_attrs = (
tuple(),