swh_scheduler = <swh.scheduler.backend.SchedulerBackend object at 0x7f98ff1921d0>
caplog = <_pytest.logging.LogCaptureFixture object at 0x7f98ff192630>
requests_ratelimited = <requests_mock.mocker.Mocker object at 0x7f98ff192940>
num_ratelimit = 1, monkeypatch_sleep_calls = [1]
lister_credentials = {'github': {'github': [{'password': 'token-legacy-0', 'username': 'swh-legacy0'}, {'password': 'token-legacy-1', 'user...: 'token-0', 'username': 'swh0'}, {'token': 'token-1', 'username': 'swh1'}, {'token': 'token-2', 'username': 'swh2'}]}}
@pytest.mark.parametrize(
"num_ratelimit", [1]
) # return a single rate-limit response, then continue
def test_ratelimit_once_recovery(
swh_scheduler,
caplog,
requests_ratelimited,
num_ratelimit,
monkeypatch_sleep_calls,
lister_credentials,
):
"""Check that the lister recovers from hitting the rate-limit once"""
caplog.set_level(logging.DEBUG, "swh.lister.github.lister")
lister = GitHubLister(scheduler=swh_scheduler, credentials=lister_credentials)
res = lister.run()
# check that we used all the pages
assert res == ListerStats(pages=NUM_PAGES, origins=ORIGIN_COUNT)
token_users = []
for record in caplog.records:
if "Using authentication token" in record.message:
token_users.append(record.args[0])
# check that we used one more token than we saw rate limited requests
> assert len(token_users) == 1 + num_ratelimit
E assert 0 == 2
E +0
E -2
.tox/py3/lib/python3.7/site-packages/swh/lister/github/tests/test_lister.py:375: AssertionError
TEST RESULT
TEST RESULT
- Run At
- Apr 25 2022, 3:49 PM