Changeset View
Changeset View
Standalone View
Standalone View
swh/web/client/tests/conftest.py
Show All 9 Lines | |||||
@pytest.fixture | @pytest.fixture | ||||
def web_api_mock(requests_mock): | def web_api_mock(requests_mock): | ||||
for api_call, data in API_DATA.items(): | for api_call, data in API_DATA.items(): | ||||
headers = {} | headers = {} | ||||
if api_call == "snapshot/cabcc7d7bf639bbe1cc3b41989e1806618dd5764/": | if api_call == "snapshot/cabcc7d7bf639bbe1cc3b41989e1806618dd5764/": | ||||
# monkey patch the only URL that require a special response headers | # monkey patch the only URL that require a special response headers | ||||
# (to make the client insit and follow pagination) | # (to make the client init and follow pagination) | ||||
headers = { | headers = { | ||||
"Link": | "Link": | ||||
f"<{API_URL}/{api_call}?branches_count=1000&branches_from=refs/tags/v3.0-rc7>; rel=\"next\"" # NoQA: E501 | f"<{API_URL}/{api_call}?branches_count=1000&branches_from=refs/tags/v3.0-rc7>; rel=\"next\"" # NoQA: E501 | ||||
} | } | ||||
requests_mock.get(f"{API_URL}/{api_call}", text=data, headers=headers) | requests_mock.get(f"{API_URL}/{api_call}", text=data, headers=headers) | ||||
return requests_mock | |||||
@pytest.fixture | @pytest.fixture | ||||
def web_api_client(): | def web_api_client(): | ||||
# use the fake base API URL that matches API data | # use the fake base API URL that matches API data | ||||
return WebAPIClient(api_url=API_URL) | return WebAPIClient(api_url=API_URL) |