-
Notifications
You must be signed in to change notification settings - Fork 1
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
Rework to allow use of metadata #13
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quite a few interesting changes indeed. I quite like the approach and functionality proposed, great addition 👍
I have added a few suggestions, changes and questions for discussion. I believe the 2 new test methods in test_unittestdb.py
could be merged into one, as it feels the functionality and objectives are very similar.
Co-authored-by: J. Alvarez-Jarreta <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We got there at the end!
Maybe too many things changed, but I needed those to ensure I can use a metadata with :
DBConnection
can now be created without a schema (dump_dir
no longer mandatory)DBConnection
accepts anMetadata
object instead of relying on an SQL file and a reflectionDBConnection
:create_all_tables
andcreate_table
(requires the metadata to be set as above)dump_dir
and ametadata
are provided to aUnitTestDB
, the schema is made from themetadata
and the data is loaded from thedump_dir
UnitTestDB
(UnitTestDBContext
)Tests:
session_scope
ortest_session_scope
to avoid hanging connections (unless we are specifically testing for that)tmp_path
to theUnitTestDB
when asked to create an SQLite database test fileUsage:
Say you want to test interactions with a whole schema described in a given metadata. You can do so with:
The first context ensures the database is properly disposed of no matter what, and the second ensures the changes are rolledback and the connection returned.