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

udpate test framework vcr cassettes #926

Merged
merged 2 commits into from
Sep 12, 2021
Merged
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
25 changes: 12 additions & 13 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,32 @@
## Testing

1. [Obtain OAuth2 credentials from Google Developers Console](http://gspread.readthedocs.org/en/latest/oauth2.html)
2. Install test requirements:

```
pip install -r test-requirements.txt
```
2. Run tests offline:

3. Run tests:
Run the test suite using your current python version, in offline mode.
This will use the curently recorded HTTP requests + responses. It does not make any HTTP call, does not require an active internet connection.

```
GS_CREDS_FILENAME=<YOUR_CREDS.json> make test
tox -e py
```

where `YOUR_CREDS.json` is a path to the file you downloaded in step 1.

**Tip:** To run a specific test method you must use the full command and append the test method name in the form of `:TestClassName.test_method_name` to `tests/test.py`.
**Tip:** To run a specific test method use the option `-k` to specifcy a test name and `-v` and `-s` to get test output on console.

Example:

```
GS_CREDS_FILENAME=<YOUR_CREDS.json> nosetests -vv tests/test.py:WorksheetTest.test_find
pytest -v -s -k "test_find" tests/
```

**Note:** gspread uses [Betamax](https://github.com/betamaxpy/betamax) to record and replay HTTP interactions with Sheets API.
You can control Betamax's [Record Mode](https://betamax.readthedocs.io/en/latest/record_modes.html) using `GS_RECORD_MODE` environment variable:
**Note:** gspread uses [vcrpy](https://github.com/kevin1024/vcrpy) to record and replay HTTP interactions with Sheets API.

You must in that case provide a service account credentials in order to make the real HTTP requests, using `GS_CREDS_FILENAME` environment variable.

You can control vcrpy's [Record Mode](https://vcrpy.readthedocs.io/en/latest/usage.html#record-modes) using `GS_RECORD_MODE` environment variable:

```
GS_RECORD_MODE=all GS_CREDS_FILENAME=<YOUR_CREDS.json> make test
GS_RECORD_MODE=all GS_CREDS_FILENAME=<YOUR_CREDS.json> tox -e py
```

## Render Documentation
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/lint_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,14 @@ jobs:
with:
python-version: ${{ matrix.python }}
- run: pip install bandit black codespell flake8 isort mypy pytest pyupgrade safety tox
- run: bandit --recursive --skip B105,B110,B311,B605,B607 .
- run: bandit --recursive --skip B105,B110,B311,B605,B607 --exclude ./.tox .
if: ${{ matrix.python >= '3.8' }}
- run: black --check .
- run: codespell # --ignore-words-list="" --skip=""
- run: flake8 --ignore=E203 --max-complexity=10 --max-line-length=255
--show-source --statistics .
- run: isort --check-only --profile black .
- run: pip install -r test-requirements.txt
- run: pytest tests/utils_test.py
- run: tox -e py || pytest . || pytest --doctest-modules . || true
- run: mypy --exclude src/betamax-json-body-serializer/setup.py --ignore-missing-imports . || true # Need Python >= 3.6
- run: tox -e py
- run: mypy --ignore-missing-imports . || true # Need Python >= 3.6
- run: shopt -s globstar && pyupgrade --py3-only **/*.py # --py36-plus
- run: safety check
7 changes: 3 additions & 4 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
six
nose
google-auth
google-auth-oauthlib>=0.4.1
betamax==0.8.1
-e git+https://github.com/burnash/betamax-json-body-serializer.git#egg=betamax_json_body_serializer
vcrpy
pytest
pytest-vcr
Loading