From 0c92300d8383044b366b5fb2c37de25ea6bc6eec Mon Sep 17 00:00:00 2001 From: Nejc Habjan Date: Thu, 30 Dec 2021 15:35:00 +0100 Subject: [PATCH] test: reproduce missing pagination headers in tests --- tests/unit/test_gitlab.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/unit/test_gitlab.py b/tests/unit/test_gitlab.py index 7664cd3ae..2981ebb87 100644 --- a/tests/unit/test_gitlab.py +++ b/tests/unit/test_gitlab.py @@ -18,6 +18,7 @@ import pickle import warnings +from copy import deepcopy import pytest import responses @@ -104,6 +105,35 @@ def test_gitlab_build_list(gl, resp_page_1, resp_page_2): assert test_list[1]["c"] == "d" +def _strip_pagination_headers(response): + """ + https://docs.gitlab.com/ee/user/gitlab_com/index.html#pagination-response-headers + """ + stripped = deepcopy(response) + + del stripped["headers"]["X-Total-Pages"] + del stripped["headers"]["X-Total"] + + return stripped + + +@pytest.mark.xfail(reason="See #1686") +@responses.activate +def test_gitlab_build_list_missing_headers(gl, resp_page_1, resp_page_2): + stripped_page_1 = _strip_pagination_headers(resp_page_1) + stripped_page_2 = _strip_pagination_headers(resp_page_2) + + responses.add(**stripped_page_1) + obj = gl.http_list("/tests", as_list=False) + assert len(obj) == 0 # Lazy generator has no knowledge of total items + assert obj.total_pages is None + assert obj.total is None + + responses.add(**stripped_page_2) + test_list = list(obj) + assert len(test_list) == 2 # List has total items after making the API calls + + @responses.activate def test_gitlab_all_omitted_when_as_list(gl, resp_page_1, resp_page_2): responses.add(**resp_page_1) 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