swh.core.github.pytest_plugin module#
- swh.core.github.pytest_plugin.fake_time_sleep(duration: float, sleep_calls: List[float] | None = None)[source]#
Record calls to time.sleep in the sleep_calls list.
- swh.core.github.pytest_plugin.monkeypatch_sleep_calls(monkeypatch) Iterator[List[float]] [source]#
Monkeypatch time.time and time.sleep. Returns a list cumulating the arguments passed to time.sleep().
- swh.core.github.pytest_plugin.num_before_ratelimit() int [source]#
Number of successful requests before the ratelimit hits
- swh.core.github.pytest_plugin.num_ratelimit() int | None [source]#
Number of rate-limited requests; None means infinity
- swh.core.github.pytest_plugin.ratelimit_reset() int | None [source]#
Value of the X-Ratelimit-Reset header on ratelimited responses
- swh.core.github.pytest_plugin.github_ratelimit_callback(request: _RequestObjectProxy, context: _Context, remaining_requests: int, ratelimit_reset: int | None) Dict[str, str] [source]#
Return a rate-limited GitHub API response.
- swh.core.github.pytest_plugin.github_repo(i: int) Dict[str, int | str] [source]#
Basic repository information returned by the GitHub API
- swh.core.github.pytest_plugin.github_response_callback(request: _RequestObjectProxy, context: _Context, remaining_requests: int, page_size: int = 1000, origin_count: int = 10000) List[Dict[str, int | str]] [source]#
Return minimal GitHub API responses for the common case where the loader hasn’t been rate-limited
- swh.core.github.pytest_plugin.github_requests_ratelimited(num_before_ratelimit: int, num_ratelimit: int | None, ratelimit_reset: int | None) Iterator[Mocker] [source]#
Mock requests to the GitHub API, returning a rate-limiting status code after num_before_ratelimit requests.
This fixture takes multiple arguments (which can be overridden with a
pytest.mark.parametrize()
parameter):num_before_ratelimit: the global number of requests until the ratelimit triggers
num_ratelimit: the number of requests that return a rate-limited response.
ratelimit_reset: the timestamp returned in X-Ratelimit-Reset if the request is authenticated.
The default values set in the previous fixtures make all requests return a rate limit response.