Skip to content

Commit 501f9a1

Browse files
nejchJohnVillalovos
authored andcommitted
test: reproduce missing pagination headers in tests
1 parent c764bee commit 501f9a1

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/unit/test_gitlab.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import pickle
2020
import warnings
21+
from copy import deepcopy
2122

2223
import pytest
2324
import responses
@@ -104,6 +105,35 @@ def test_gitlab_build_list(gl, resp_page_1, resp_page_2):
104105
assert test_list[1]["c"] == "d"
105106

106107

108+
def _strip_pagination_headers(response):
109+
"""
110+
https://docs.gitlab.com/ee/user/gitlab_com/index.html#pagination-response-headers
111+
"""
112+
stripped = deepcopy(response)
113+
114+
del stripped["headers"]["X-Total-Pages"]
115+
del stripped["headers"]["X-Total"]
116+
117+
return stripped
118+
119+
120+
@pytest.mark.xfail(reason="See #1686")
121+
@responses.activate
122+
def test_gitlab_build_list_missing_headers(gl, resp_page_1, resp_page_2):
123+
stripped_page_1 = _strip_pagination_headers(resp_page_1)
124+
stripped_page_2 = _strip_pagination_headers(resp_page_2)
125+
126+
responses.add(**stripped_page_1)
127+
obj = gl.http_list("/tests", as_list=False)
128+
assert len(obj) == 0 # Lazy generator has no knowledge of total items
129+
assert obj.total_pages is None
130+
assert obj.total is None
131+
132+
responses.add(**stripped_page_2)
133+
test_list = list(obj)
134+
assert len(test_list) == 2 # List has total items after making the API calls
135+
136+
107137
@responses.activate
108138
def test_gitlab_all_omitted_when_as_list(gl, resp_page_1, resp_page_2):
109139
responses.add(**resp_page_1)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy