-
-
Notifications
You must be signed in to change notification settings - Fork 27
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
Adding Python Tests #121
base: main
Are you sure you want to change the base?
Adding Python Tests #121
Conversation
Duplicated the project information to the tool.poetry section so that using poetry works.
Added shell.nix file which creates a virtual environment using poetry and installs the necessary requirements. Added requirements to the pyproject.toml file under the tool.poetry.dependencies section. Added poetry.lock file for reproducability on non-nix systems. Updated README to include information about nix-shell environment. Execute using `nix-shell` command.
When patching the MongoClient for tests, the patch is applied only to lookup calls exactly matching pymongo.MongoClient so the import must be changed to be exactly this.
Imports for join_url must come from openf1.util.misc.
Tests for the openf1 package using pytest. Added unit tests for: - db utils - misc utils - type_casting utils Added fixture for mongodb to use with database tests. Added mongodb fixture data using first 10 entries of 2024 season.
#120 has been merged with a few conflicts, so conflicts were resolved. Current there are only 13 unit tests. 3 tests fail because they expect utility functions to raise an error when bad data is put in (this shouldn't happen in the modules code, I think?) Suggestions for branch management with tests:
Additionally, I didn't notice a linting file; should we also integrate |
Hello @PrestonHager, When I run the tests locally, 4 of them (out of 9) are failing. Is it the same for you?
|
Yes the four failing tasks, I wrote that way on purpose. The functions they are testing assume no wrong input values which may be a fine precondition and we could remove the tests. The tests are specifically written to raise a Also the |
Added tests using the
pytest
module. They can be run withpytest tests
in the root directory.Only unit tests for the utility files have been added. A fixture for mongodb is included.
This branch does include the
join_url
from theurl-fix
branch which means this should only get merged if #120 is merged. Other than that, the files in this branch have no operational impacts and are only used for development purposes. There are currently 13 total tests for three different utility files.Plans for the future:
requests
fixture for any web related data