Add cassettes and modify testing to enable testing without internet #443
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is unfinished and will still be modified a bit, but it is a good proof-of-concept for what I'm trying to do. tests/conftest.py has a pytest fixture in it which automatically handles logic related to vcrpy. Simply adding the argument
vcr
to any function will enable vcrpy for the function and will use/create the cassette with the function name in the cassette directory. With test classes, it is slightly more complex to use fixtures in class methods, and for this reason I added a class called FixtureInjector using an example from pytest docs. Further, this simplifies the use of vcr cassettes by not requiring function decorators with the correct path for every function you want to use cassettes for, which results in less work to use vcrpy.Excluding the cassette directory, this commit currently adds 49 lines and removes 15 across
tests/conftest.py
andtests/test_buku{,Db}.py
. I did some execution time testing as well by executing the commandpytest tests/test_buku.py tests/test_bukuDb.py
on the HEAD commit of both my and your repositories, 5 times each. Using the time returned by pytest, the average for your repository was 275.29 seconds, and the average in my repository was 59.19 seconds. In other words, using cassettes for the functions in these two test files sped up the test execution time by several minutes on my machine. This variability is completely attributed to the lack of network-related hangs during testing using the modifications in my repository.Please keep in mind this is a work in progress and I still have some cleaning up to do with it, should you be interested in these changes.