BDMS 22+: implement sample model | some pytest cleanup | pre-commit hooks#49
Conversation
This commit drops the `idx_location_point` index from the `location` table. The index was causing issues with the database schema because it is automatically created by SQLAlchemy when the `location` table is defined.
configure_mappers() to ensure all models are registered and ready for migration.
This is to be used by all endpoints where a resource is not found when an id is given as part of a path parameter
The id changes because of autoincrement in the database, so use the fixture's sample id instead of a hardcoded value.
This note has been addressed in another development branch and is no longer relevant in this context.
fixtures were moved to conftest.py to allow for better organization and reuse across multiple test files. This change helps in maintaining cleaner test code and improves the overall structure of the test suite.
Tests that post and patch data need to be undone for fixtures that are used in the full session
|
Alembic migrations do not need to be used for the tests. This seems to be a continuing source of complexity and is not necessary. These unit tests are not for testing database migrations, they are for testing that the API functions correctly. |
|
That makes sense that these are API tests. Would we have a database testing suite, though, to ensure that it's all built and working as expected? |
jirhiker
left a comment
There was a problem hiding this comment.
The sample api looks good and the use of fixtures in the tests is an improvement
But I do not like the use of alembic in the tests. It seems unnecessary and adds complexity that is a distraction from the true purpose of the tests
These tests are for the API, not for the database, so no need to use Alembic migrations
|
I'm now using |
Use this instead of session: Depends(get_db_session) in POST /sample endpoint to keep a consistent style.
Why
This PR addresses the following problem / context:
tests/conftest.pyfor repeated use and retrieval throughout the testing suite.How
Implementation summary - the following was changed / added / removed:
/sampleroutertests/conftest.pyfor use throughout the testing suitesNotes
Any special considerations, workarounds, or follow-up work to note?
pre-production(the fixtures in particular)REFACTOR NOTE/TODOfor future ideas/work