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 all network traffic when using VCR cassettes for unit tests #207

Merged
merged 2 commits into from Jun 25, 2018

Conversation

valgur
Copy link
Member

@valgur valgur commented Jun 21, 2018

Disable the socket.socket interface to block all network traffic when running unit tests against prerecorded queries. This should make writing unit tests a bit easier by explicitly enforcing our convention of not doing any network requests by default when running unit tests.

I wanted to add this very minor enhancement already about a year ago, but the pytest-socket extension needed some tweaking first for this to work in a reasonable manner.

@kr-stn
Copy link
Member

kr-stn commented Jun 22, 2018

Should we document this somewhere, so people writing new tests are not caught off-guard? Or do you think the documentation of the usage of VCR and how to record new responses is enough?

I tend towards the latter.

@codecov
Copy link

codecov bot commented Jun 24, 2018

Codecov Report

Merging #207 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #207   +/-   ##
=======================================
  Coverage   95.36%   95.36%           
=======================================
  Files           3        3           
  Lines         539      539           
  Branches      110      110           
=======================================
  Hits          514      514           
  Misses         16       16           
  Partials        9        9

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4de1023...22ddc93. Read the comment docs.

@valgur
Copy link
Member Author

valgur commented Jun 24, 2018

Good point. The exception raised in case of inadvertent network accesses is not really super clear about its intended purpose (pytest_socket.SocketBlockedError: A test tried to use socket.socket.), so I added a small explanation of this feature to CONTRIBUTE.rst.

@kr-stn
Copy link
Member

kr-stn commented Jun 25, 2018

Perfect 👍

@kr-stn kr-stn merged commit 26ca60c into sentinelsat:master Jun 25, 2018
valgur added a commit that referenced this pull request Sep 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants