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

Block network requests during unit tests #119

Merged
Merged
Show file tree
Hide file tree
Changes from 3 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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Developer

- Adds `--block-network` option to all test commands to ensure no network requests are made during unit tests
[#119](https://github.com/stac-utils/pystac-client/pull/119)

## [0.3.0] - 2021-09-28

### Added
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ $ pip install -r requirements-dev.txt
To run just the tests

```shell
$ pytest -v -s --cov pystac_client --cov-report term-missing
$ pytest -v -s --block-network --cov pystac_client --cov-report term-missing
```

The pystac-client tests use [vcrpy](https://vcrpy.readthedocs.io/en/latest/) to mock API calls
Expand All @@ -46,7 +46,7 @@ function to indicate `vcrpy` should be used. Record the new responses and commit
repository.

```shell
$ pytest -v -s --record-mode new_episodes
$ pytest -v -s --record-mode new_episodes --block-network
$ git add <new files here>
$ git commit -a -m 'new test episodes'
```
Expand All @@ -55,7 +55,7 @@ To update pystac-client to use future versions of STAC API, the existing recorde
should be "re-recorded":

```shell
$ pytest -v -s --record-mode rewrite
$ pytest -v -s --record-mode rewrite --block-network
$ git commit -a -m 'updated test episodes'
```

Expand Down
2 changes: 1 addition & 1 deletion scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
*.md

# Test suite with coverage enabled
pytest -s --cov pystac_client --cov-report term-missing
pytest -s --block-network --cov pystac_client --cov-report term-missing
coverage xml
fi
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
interactions:
- request:
body: '{"bbox": [-73.21, 43.99, -73.12, 44.05], "query": {"gsd": {"eq": 10.0}}}'
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '72'
Content-Type:
- application/json
User-Agent:
- python-requests/2.26.0
method: POST
uri: https://planetarycomputer.microsoft.com/api/stac/v1/search
response:
body:
string: !!binary |
H4sIAFRgjWEC/+1Ya2/bNhT9K4Q/FAkmS3KspLGHYCjWdg9gXbBk+7AiCGiJltlKokZSdryi/33n
UrZFO48B25Kum4M8HJG899xzH7y6H3p2WYveuPdacNto8bUqCpFaqape0Ju2z0xv/PZDT2bYVSXH
i/h50h8MsTyZqBss9Z8nYRzHx+7reZAMw9FolLivk6D//Kj7dxQkx93W5CrYUQ6Zhazet/q0KLCS
+nhWu3ldFzLl9DB6Z9zKTIspVmbW1mYcRXXBK2G5XqaqrBsrdFjKVCujpjbEo4jXMjKWp9F8EHUa
TDTMRN03gpeFMKb3MVijqLkWlf2UCLRSj6bfU2NEMb1bTS7UF49oaiStKE3kxVcHihcQWnErHiTA
SlvQkpWQ91Qoo1Zbh3Uu+W3dXCYi45aLZiGMDSeFmkCnFuFCVplamBDInKLoVSHmrVWQffnd69dr
XdHPF99cXA+G16v/w5uy8ANUi7kUi79mNkEjs8m4qOT1V539Z1vmP6MdZ1s1YM36D7xmaspoQ+cl
K25sNLOEFLnOjREWuf2hRwrp7xPQZKUXz7LkuYDLptMvmRdBZ4jt9mGt1RQOPUsL1WR9VVtZyt9F
BglaFa4OttivOsNJIRtEQ8Z1CqJSVWVspZwN2A1+MpFrQbGbCZNqWbtiNu5dzqRhFD7Em50JNnzJ
Nnaxc61yzUt2MHz56vyQrT1ACLMmtYbh8I5WFGpVNHQ6ZIyOMcKKo3ouGDdOh9goKPhSaFJ9icdv
3DNeMLgxYBzCoGcuM8Em3MjUOyarqd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YcuQd4ruiu6PK/4FGeK01pF8Pt8TG64mftW3uGcl6hlNU/uvripfijK5V
BPAzZCHqpzjrD/AuHCT49eCLTceKe9cgRlo7RXa97vs9Zn5arbHuneCffkdYSQrrKn98Yjbm00Xn
DLjaiR7A6H2koiBcGVs6NtoN56pY5o5F7+qGsLdv/cGEP7O4CnaWNhOLE7e0mXWcPLj0gEBv6Yqc
6Y04xr3t9/8ATlNUiKVwL065yXrjQRzQWwiqdEkmovKO+jEYPrmM47H7/rU9+G4saoMyeZyMTlcP
zIwTL28H8engKHC/wSYi5npb4mk/Pu7Ho9sSrUaBp54GQmKyNx4dHdP3MMC/wc4syD3a2bY1AnI7
6GcQxgDibpQ7oWwbZxHBAkyNtchb3qokXpzGdDXQS/w1tYztAgSHFEbuMd5HRUULLqDW8U9L/W4p
zFFSmkkoVUQmt65B7JOgyKQzUXJXEygTN2Ox5E/HYt4cbLg9FkNMeFtP9mOx/Vjs1sAp+SzGYskT
jsWSneYi+eRjseTfOBa7m6ZPNBZL9mOx/VhsPxbbj8X2Y7H9WGw/Fvs8xmLJaiyWfAZjsfubwn/R
WOxukP/NsViyH4s9DjFPMhY7un+Kldw/+3pg6QGBR//zsZg/AvrMx2JXtwdWn3xQ8/fVtO9SeGf/
+Adpc2ReNScAAA==
headers:
Content-Encoding:
- gzip
Content-Length:
- '1891'
Content-Type:
- application/json
Date:
- Thu, 11 Nov 2021 18:26:30 GMT
Strict-Transport-Security:
- max-age=15724800; includeSubDomains
Vary:
- Accept-Encoding
X-Azure-Ref:
- 0VGCNYQAAAABBCsHGOKgFRKAFtUqjfhe1Qk9TMzFFREdFMDUxMAA5MjdhYmZhNi0xOWY2LTRhZjEtYTA5ZC1jOTU5ZDlhMWU2NDQ=
X-Cache:
- CONFIG_NOCACHE
status:
code: 200
message: OK
- request:
body: '{"bbox": [-73.21, 43.99, -73.12, 44.05], "query": {"gsd": {"eq": 10}}}'
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '70'
Content-Type:
- application/json
User-Agent:
- python-requests/2.26.0
method: POST
uri: https://planetarycomputer.microsoft.com/api/stac/v1/search
response:
body:
string: !!binary |
H4sIAFdgjWEC/+1Ya2/bNhT9K4Q/FAkmS3KspLGHYCjWdg9gXbBk+7AiCGiJltlKokZSdryi/33n
UrZFO48B25Kum4M8HJG899xzH7y6H3p2WYveuPdacNto8bUqCpFaqape0Ju2z0xv/PZDT2bYVSXH
i/h50h8MsTyZqBss9Z8nYRzHx+7reZAMw9FolLivk6D//Kj7dxQkx93W5CrYUQ6Zhazet/q0KLCS
+nhWu3ldFzLl9DB6Z9zKTIspVmbW1mYcRXXBK2G5XqaqrBsrdFjKVCujpjbEo4jXMjKWp9F8EHUa
TDTMRN03gpeFMKb3MVijqLkWlf2UCLRSj6bfU2NEMb1bTS7UF49oaiStKE3kxVcHihcQWnErHiTA
SlvQkpWQ91Qoo1Zbh3Uu+W3dXCYi45aLZiGMDSeFmkCnFuFCVplamBDInKLoVSHmrVWQffnd69dr
XdHPF99cXA+G16v/w5uy8ANUi7kUi79mNkEjs8m4qOT1V539Z1vmP6MdZ1s1YM36D7xmaspoQ+cl
K25sNLOEFLnOjREWuf2hRwrp7xPQZKUXz7LkuYDLptMvmRdBZ4jt9mGt1RQOPUsL1WR9VVtZyt9F
BglaFa4OttivOsNJIRtEQ8Z1CqJSVWVspZwN2A1+MpFrQbGbCZNqWbtiNu5dzqRhFD7Em50JNnzJ
Nnaxc61yzUt2MHz56vyQrT1ACLMmtYbh8I5WFGpVNHQ6ZIyOMcKKo3ouGDdOh9goKPhSaFJ9icdv
3DNeMLgxYBzCoGcuM8Em3MjUOyarqdJl+xmf2Cuu7YyZVIoqFczYJpPCOAkIpFpWuU80UFcOxs8V
AiVjFxZJbUJ2QcetNLY9SYY0GuJKXsFh2rDGCM8i0psjOIA3nfEqF3RCgIlZwGbLDK5SOUCXKhO4
TvLAE6igWGn3cIMPGufSNLyQvzuUwQp+tWQKYPWWB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dv/cGEP7O4CnaWNhOLE7e0mXWcPLj0gEBv6Yqc
6Y04xr3t9/8ATlNUiKVwL065yXrjQRzQWwiqdEkmovKO+jEYPrmM47H7/rU9+G4saoMyeZyMTlcP
zIwTL28H8engKHC/wSYi5npb4mk/Pu7Ho9sSrUaBp54GQmKyNx4dHdP3MMC/wc4syD3a2bY1AnI7
6GcQxgDibpQ7oWwbZxHBAkyNtchb3qokXpzGdDXQS/w1tYztAgSHFEbuMd5HRUULLqDW8U9L/W4p
zFFSmkkoVUQmt65B7JOgyKQzUXJXEygTN2Ox5E/HYt4cbLg9FkNMeFtP9mOx/Vjs1sAp+SzGYskT
jsWSneYi+eRjseTfOBa7m6ZPNBZL9mOx/VhsPxbbj8X2Y7H9WGw/Fvs8xmLJaiyWfAZjsfubwn/R
WOxukP/NsViyH4s9DjFPMhY7un+Kldw/+3pg6QGBR//zsZg/AvrMx2JXtwdWn3xQ8/fVtO9SeGf/
+Adpc2ReNScAAA==
headers:
Content-Encoding:
- gzip
Content-Length:
- '1891'
Content-Type:
- application/json
Date:
- Thu, 11 Nov 2021 18:26:32 GMT
Strict-Transport-Security:
- max-age=15724800; includeSubDomains
Vary:
- Accept-Encoding
X-Azure-Ref:
- 0VmCNYQAAAADpEXziNyGVQa/WlpSRtwH4Qk9TMzIxMDAwMTA5MDQ1ADkyN2FiZmE2LTE5ZjYtNGFmMS1hMDlkLWM5NTlkOWExZTY0NA==
X-Cache:
- CONFIG_NOCACHE
status:
code: 200
message: OK
version: 1
1 change: 1 addition & 0 deletions tests/test_item_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ def test_get_all_items(self):


class TestItemSearchQuery:
@pytest.mark.vcr
def test_query_shortcut_syntax(self):
search = ItemSearch(url=SEARCH_URL,
bbox=(-73.21, 43.99, -73.12, 44.05),
Expand Down