swh_scheduler = <swh.scheduler.backend.SchedulerBackend object at 0x7f14a856da58>
requests_mock = <requests_mock.mocker.Mocker object at 0x7f14a856db70>
http_code = 500
@pytest.mark.parametrize("http_code", [400, 500, 502])
def test_gitea_list_http_error(swh_scheduler, requests_mock, http_code):
"""Test handling of some HTTP errors commonly encountered"""
lister = GiteaLister(scheduler=swh_scheduler, url=TRYGITEA_URL, page_size=3)
base_url = TRYGITEA_URL + lister.REPO_LIST_PATH
requests_mock.get(base_url, status_code=http_code)
with pytest.raises(requests.HTTPError):
> lister.run()
.tox/py3/lib/python3.7/site-packages/swh/lister/gitea/tests/test_lister.py:150:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.7/site-packages/swh/lister/pattern.py:127: in run
for page in self.get_pages():
.tox/py3/lib/python3.7/site-packages/swh/lister/gogs/lister.py:164: in get_pages
next_link, {**self.query_params, "page": page_id}
.tox/py3/lib/python3.7/site-packages/tenacity/__init__.py:324: in wrapped_f
return self(f, *args, **kw)
.tox/py3/lib/python3.7/site-packages/tenacity/__init__.py:404: in __call__
do = self.iter(retry_state=retry_state)
.tox/py3/lib/python3.7/site-packages/tenacity/__init__.py:349: in iter
return fut.result()
/usr/lib/python3.7/concurrent/futures/_base.py:425: in result
return self.__get_result()
/usr/lib/python3.7/concurrent/futures/_base.py:384: in __get_result
raise self._exception
.tox/py3/lib/python3.7/site-packages/tenacity/__init__.py:407: in __call__
result = fn(*args, **kwargs)
.tox/py3/lib/python3.7/site-packages/swh/lister/gogs/lister.py:140: in page_request
query.update({"page": _parse_page_id(url) + 1})
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
url = 'https://try.gitea.io/api/v1/repos/search'
def _parse_page_id(url: Optional[str]) -> int:
"""Parse the page id from a Gogs page url."""
if url is None:
return 0
> return int(parse_qs(urlparse(url).query)["page"][0])
E KeyError: 'page'
.tox/py3/lib/python3.7/site-packages/swh/lister/gogs/lister.py:46: KeyError
TEST RESULT
TEST RESULT
- Run At
- Sep 20 2022, 1:21 PM