Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0c92300

Browse files
committed
test: reproduce missing pagination headers in tests
1 parentc764bee commit0c92300

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
importpickle
2020
importwarnings
21+
fromcopyimportdeepcopy
2122

2223
importpytest
2324
importresponses
@@ -104,6 +105,35 @@ def test_gitlab_build_list(gl, resp_page_1, resp_page_2):
104105
asserttest_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+
delstripped["headers"]["X-Total-Pages"]
115+
delstripped["headers"]["X-Total"]
116+
117+
returnstripped
118+
119+
120+
@pytest.mark.xfail(reason="See #1686")
121+
@responses.activate
122+
deftest_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+
assertlen(obj)==0# Lazy generator has no knowledge of total items
129+
assertobj.total_pagesisNone
130+
assertobj.totalisNone
131+
132+
responses.add(**stripped_page_2)
133+
test_list=list(obj)
134+
assertlen(test_list)==2# List has total items after making the API calls
135+
136+
107137
@responses.activate
108138
deftest_gitlab_all_omitted_when_as_list(gl,resp_page_1,resp_page_2):
109139
responses.add(**resp_page_1)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp