-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(tests): Expect tests to fail if GH API limit reached
A bit of a hack...
- Loading branch information
Showing
5 changed files
with
28 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,30 @@ | ||
import os | ||
from pathlib import Path | ||
|
||
import pytest | ||
import requests | ||
|
||
TESTS_DIR = Path(__file__).parent | ||
DATA_DIR = TESTS_DIR / "test_data" | ||
RESUMES_DIR = DATA_DIR / "resumes" | ||
RESUMES = {p.name: p for p in RESUMES_DIR.iterdir()} | ||
|
||
GH_TOKEN = os.environ.get("GH_TOKEN", None) | ||
|
||
# Probably a terrible idea to do IO using the GH API in unit tests, but it does test the | ||
# full thing instead of just some mock. | ||
headers = { | ||
"Accept": "application/vnd.github+json", | ||
"User-Agent": "ancv-pytest", | ||
} | ||
if GH_TOKEN is not None: | ||
headers["Authorization"] = f"Bearer {GH_TOKEN}" | ||
|
||
resp = requests.get( | ||
"https://api.github.com/rate_limit", | ||
headers=headers, | ||
) | ||
gh_rate_limited = pytest.mark.xfail( | ||
condition=resp.json()["resources"]["core"]["remaining"] == 0, | ||
reason="GitHub API rate limit reached. If you haven't already, set the 'GH_TOKEN' env var to a PAT.", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters