Skip to content

Commit 3e2d694

Browse files
Merge pull request #963 from python-gitlab/fix/as_list
Fix/as list
2 parents 18913dd + b5e88f3 commit 3e2d694

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
dist: bionic
2424
python: 3.7
2525
script:
26-
- pip3 install black
26+
- pip3 install -U --pre black
2727
- black --check .
2828
- stage: test
2929
name: cli_func_v4

gitlab/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ def http_list(self, path, query_data=None, as_list=None, **kwargs):
630630
get_all = kwargs.pop("all", False)
631631
url = self._build_url(path)
632632

633-
if get_all is True:
633+
if get_all is True and as_list is True:
634634
return list(GitlabList(self, url, query_data, **kwargs))
635635

636636
if "page" in kwargs or as_list is True:

gitlab/tests/test_gitlab.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,24 @@ def resp_2(url, request):
119119
self.assertEqual(l[0]["a"], "b")
120120
self.assertEqual(l[1]["c"], "d")
121121

122+
def test_all_omitted_when_as_list(self):
123+
@urlmatch(scheme="http", netloc="localhost", path="/api/v4/tests", method="get")
124+
def resp(url, request):
125+
headers = {
126+
"content-type": "application/json",
127+
"X-Page": 2,
128+
"X-Next-Page": 2,
129+
"X-Per-Page": 1,
130+
"X-Total-Pages": 2,
131+
"X-Total": 2,
132+
}
133+
content = '[{"c": "d"}]'
134+
return response(200, content, headers, None, 5, request)
135+
136+
with HTTMock(resp):
137+
result = self.gl.http_list("/tests", as_list=False, all=True)
138+
self.assertIsInstance(result, GitlabList)
139+
122140

123141
class TestGitlabHttpMethods(unittest.TestCase):
124142
def setUp(self):

gitlab/v4/objects.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -762,8 +762,8 @@ class GroupClusterManager(CRUDMixin, RESTManager):
762762
_obj_cls = GroupCluster
763763
_from_parent_attrs = {"group_id": "id"}
764764
_create_attrs = (
765-
("name", "platform_kubernetes_attributes",),
766-
("domain", "enabled", "managed", "environment_scope",),
765+
("name", "platform_kubernetes_attributes"),
766+
("domain", "enabled", "managed", "environment_scope"),
767767
)
768768
_update_attrs = (
769769
tuple(),
@@ -1664,8 +1664,8 @@ class ProjectClusterManager(CRUDMixin, RESTManager):
16641664
_obj_cls = ProjectCluster
16651665
_from_parent_attrs = {"project_id": "id"}
16661666
_create_attrs = (
1667-
("name", "platform_kubernetes_attributes",),
1668-
("domain", "enabled", "managed", "environment_scope",),
1667+
("name", "platform_kubernetes_attributes"),
1668+
("domain", "enabled", "managed", "environment_scope"),
16691669
)
16701670
_update_attrs = (
16711671
tuple(),

0 commit comments

Comments
 (0)