Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions gitlab/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,19 @@ def http_list(

page = kwargs.get("page")

if iterator and page is not None:
arg_used_message = f"iterator={iterator}"
if as_list is not None:
arg_used_message = f"as_list={as_list}"
utils.warn(
message=(
f"`{arg_used_message}` and `page={page}` were both specified. "
f"`{arg_used_message}` will be ignored and a `list` will be "
f"returned."
),
category=UserWarning,
)

if iterator and page is None:
# Generator requested
return GitlabList(self, url, query_data, **kwargs)
Expand Down
13 changes: 12 additions & 1 deletion tests/unit/test_gitlab_http_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,11 +548,22 @@ def test_list_request_page_and_iterator(gl):
response_dict["match"] = [responses.matchers.query_param_matcher({"page": "1"})]
responses.add(**response_dict)

result = gl.http_list("/projects", iterator=True, page=1)
with pytest.warns(
UserWarning, match="`iterator=True` and `page=1` were both specified"
):
result = gl.http_list("/projects", iterator=True, page=1)
assert isinstance(result, list)
assert len(result) == 20
assert len(responses.calls) == 1

with pytest.warns(
UserWarning, match="`as_list=False` and `page=1` were both specified"
):
result = gl.http_list("/projects", as_list=False, page=1)
assert isinstance(result, list)
assert len(result) == 20
assert len(responses.calls) == 2


large_list_response = {
"method": responses.GET,
Expand Down