Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set http caching for tests #207

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
a7c44e3
Set http caching for tests
tgrandje Aug 8, 2024
36cc789
Remove version check from unittests
tgrandje Aug 9, 2024
a3de263
Update conftest.py
tgrandje Aug 27, 2024
8ebea8b
Restore insee secrets on local machine after tests
tgrandje Aug 27, 2024
1bb34c7
First try to store artifacts on SSP Cloud
tgrandje Aug 27, 2024
8cc05f0
Update conftest.py
tgrandje Aug 28, 2024
0955cb0
Add hash check of cache before/after session
tgrandje Aug 28, 2024
c234300
Fix typo
tgrandje Aug 28, 2024
fc94a0a
Handle missing cache
tgrandje Aug 29, 2024
ec945f8
Update .gitignore
tgrandje Aug 29, 2024
f1791a7
Add compression of archived cache
tgrandje Aug 30, 2024
b5302b6
Preserve proxies during tests
tgrandje Aug 30, 2024
1b7fa7c
Merge branch 'enhancement/tests_requests_patching' of https://github.…
tgrandje Aug 30, 2024
bcb8f1c
Store proxy to crendentials for perservation during tests
tgrandje Aug 30, 2024
4a39255
Add log entries to pytest session load/teardown + flag bugfix
tgrandje Aug 30, 2024
47eb542
Fix tests exception types
tgrandje Aug 30, 2024
2005993
Better credentials persistence and systemic tempfiles removal before …
tgrandje Aug 30, 2024
c40c504
Merge branch 'master' into enhancement/tests_requests_patching
tgrandje Aug 30, 2024
680cc1f
Bugfix new credentials with proxy from os.environ
tgrandje Aug 30, 2024
55277ad
Remove previous credentials persistence patch
tgrandje Aug 30, 2024
d158177
Bugfix on exception type
tgrandje Aug 30, 2024
f6b92a6
Run test sequentialy to ensure proper caching
tgrandje Aug 30, 2024
5552528
Fix missing application type
tgrandje Sep 2, 2024
92e81ea
Revert "Fix missing application type"
tgrandje Sep 3, 2024
013ccb2
Fix headers matching
tgrandje Sep 3, 2024
7f42bec
Add timers for benchmark
tgrandje Sep 3, 2024
4d22025
Test filesystem backend
tgrandje Sep 3, 2024
ade2acc
Fix cleanup/restoration for filesystem backend
tgrandje Sep 4, 2024
ced1cbf
Fix UnboundLocalError
tgrandje Sep 4, 2024
644d037
Store first benchmark results in project
tgrandje Sep 4, 2024
851edc6
Reset backend to SQLite and Linux exceptions fixed
tgrandje Sep 4, 2024
b7745ae
Remove temp poetry files & benchmark
tgrandje Sep 4, 2024
76190d5
Moved _get_credentials fix to different PR
tgrandje Sep 4, 2024
be1e272
Moved _request_insee exception fixes to different PR
tgrandje Sep 4, 2024
a84e595
Manage corrupted 7z archive
tgrandje Sep 12, 2024
f4fa8f8
Revert exception type in tests (moved to another PR)
tgrandje Sep 12, 2024
8eee51b
Fix conftest with missing/incomplete/invalid SSPCloud credentials
tgrandje Sep 18, 2024
f4913ee
Fix typo
tgrandje Sep 18, 2024
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: 3 additions & 1 deletion .github/workflows/pkgTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.12"]

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -46,6 +46,8 @@ jobs:
# run all py files
# for f in *.py; do python "$f"; done
cd ../..
- name: Add requests-cache
run: pip install requests-cache # Used to monkeypatch requests
- name: Test with pytest
env:
insee_key: ${{ secrets.INSEE_KEY }}
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/pkgTests_pull_requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.12"]

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -48,6 +48,8 @@ jobs:
# run all py files
# for f in *.py; do python "$f"; done
cd ../..
- name: Add requests-cache
run: pip install requests-cache # Used to monkeypatch requests
- name: Test with pytest
env:
insee_key: ${{ secrets.INSEE_KEY }}
Expand Down
26 changes: 26 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import os
try:
import requests_cache
except ModuleNotFoundError:
pass
import platformdirs
import warnings


def pytest_sessionstart(session):
"Add cache to reduce test duration over multiple python version"

appname = "pynsee-test-http-cache"
cache_dir = platformdirs.user_cache_dir(appname, ensure_exists=True)
try:
requests_cache.install_cache(
cache_name=os.path.join(cache_dir, "requests-cache.sqlite")
)
except NameError:
warnings.warn(
"requests-cache not preset, http caching will be deactivated "
"during tests"
)
Loading