Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ jobs:
run: uv python pin ${{ matrix.settings.python }}
- name: Sync dependencies
run: uv sync
- name: Setup cache
run: |
git submodule update --init
hatch run setup-cache
- name: Setup mongo
run: hatch run mongo:start
- name: Test with pytest
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ requests-cache.sqlite
.cursorignore
/cache
/data
/tests/cache
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "tests/cache"]
path = tests/cache
url = https://github.com/satyaog/paperoni-testscache.git
10 changes: 9 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ make-secrets = [
'serieux patch -m "paperoni.config:gifnoc_model" -f "{env:PAPERONI_SECRETS}" -o "$(echo "{env:GIFNOC_FILE}" | cut -d"," -f1)" {args}',
'cp $(dirname "{env:PAPERONI_SECRETS}")/*focuses*.yaml "$(dirname "$(echo "{env:GIFNOC_FILE}" | cut -d"," -f1)")"',
]
setup-cache = [
"gzip --decompress --force --keep {root:real}/tests/cache/cache.tar.gz",
"tar -xf {root:real}/tests/cache/cache.tar -C {root:real}/tests/cache",
]
save-cache = [
"cd {root:real}/tests/cache && tar -cf cache.tar --exclude 'cache.tar*' --uid 0 --gid 0 $(find * -type f | sort)",
"gzip --force --keep --no-name -1 {root:real}/tests/cache/cache.tar",
]

[tool.hatch.envs.hatch-test]
installer = "uv"
Expand All @@ -120,8 +128,8 @@ post-install-commands = [
[tool.hatch.envs.hatch-test.extra-scripts]
uv = 'UV_PROJECT_ENVIRONMENT="{env:VIRTUAL_ENV}" "$(which uv)" {args}'
mongo = [
"uv sync --inexact",
"hatch run mongo:restart",
"uv sync --inexact",
"run {args}",
"hatch run mongo:stop",
]
Expand Down
1 change: 1 addition & 0 deletions tests/cache
Submodule cache added at 0d728e
10 changes: 8 additions & 2 deletions tests/config/test-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,21 @@ paperoni:
fetch:
$class: RulesFetcher
rules:
"^https://api.biorxiv.org/": cloudflare
"^https://www.biorxiv.org/": cloudflare
"^https://www.medrxiv.org/": cloudflare
".*": cached
"^https://pmc.ncbi.nlm.nih.gov/": cached
".*": cached_ua
fetchers:
cached:
cached_ua:
$class: CachedFetcher
cache_path: ${paperoni.cache_path}/requests-cache.sql
expire_after: 7d
user_agent: chrome
cached:
$class: CachedFetcher
cache_path: ${paperoni.cache_path}/requests-cache.sql
expire_after: 7d
cloudflare:
$class: CloudFlareFetcher
user_agent: chrome
Expand Down
8 changes: 6 additions & 2 deletions tests/refinement/test_fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def test__test_tags(f_tags, tags, pass_):

# biorxiv links sometimes fails with requests.exceptions.HTTPError: 421 Client
# Error: Misdirected Request
links_w_redirect_errors = {
links_w_errors = {
"10.1101/2020.10.29.359778",
"10.1101/2023.05.17.541168",
"10.1101/2023.10.27.564468",
Expand All @@ -116,7 +116,11 @@ def test_refine(func, link, data_regression):
data = serialize(Paper, result)
data_regression.check(data)
except requests.exceptions.HTTPError as e:
if e.response.status_code == 421 and link in links_w_redirect_errors:
if e.response.status_code == 403 and link in links_w_errors:
pytest.skip(
f"{link} fails with a forbidden request ending in error {e.response.status_code}"
)
elif e.response.status_code == 421 and link in links_w_errors:
pytest.skip(
f"{link} fails with a misdirected request ending in error {e.response.status_code}"
)
Expand Down
Loading