-
Notifications
You must be signed in to change notification settings - Fork 208
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
🧪 TESTS: SQLA Migrations -> pytest #5192
🧪 TESTS: SQLA Migrations -> pytest #5192
Conversation
Thanks a lot @chrisjsewell ! I haven't looked at the code yet, but just from reading your PR description:
I don't know how others feel about this but to me "current" and "latest" are rather easily confused - not when seeing them together like this, but if I just see a Given the choice between the old and new naming schemes I would probably stick with the old, but of course open to better alternatives. |
I agree with @ltalirz . I am not married to the current choice, but I definitely think that |
Firstly, I would note
As I have discussed in #5154, really there is an element missing here, which is a version that can be used to compare different backends, i.e. currently the "head" schema for Django ( |
Would be fine with |
Yep sounds good, I've changed the names to these, so ready for review |
Codecov Report
@@ Coverage Diff @@
## develop #5192 +/- ##
===========================================
+ Coverage 81.38% 81.43% +0.05%
===========================================
Files 529 529
Lines 37002 37002
===========================================
+ Hits 30112 30129 +17
+ Misses 6890 6873 -17
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
@ltalirz you also happy with |
########################################################################### | ||
"""Tests migration of the keys of certain attribute for ProcessNodes and CalcJobNodes.""" | ||
from .conftest import Migrator | ||
|
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.
Why separate out some of these migration tests to separate files, but not all of them? Feels a bit arbitrary to take a few out but still leave a lot of them in test_other.py
...
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.
Yeh fair: I felt it was too much for one file (as before), but overkill to split every migration into a separate file.
I've now split them up a bit better; trying to group them in related/sequential migrations, and added numbering to the file names, to make it easier to see the order.
this is ready for re-review cheers @sphuber |
Ah what a pain in the backside: |
Ah this so ***ing annoying, it runs fine locally, but here it hangs on a migration for some reason |
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
Yeh err there is just something causing locking of the database in the migration tests, and it seems different whether you are using the test database automatically created by pgtest (what I do locally) or created upfront then setting Note this only affects the tests, not running the migrations manually It is the same thing I've encountered in #5097 (comment) @sphuber / @giovannipizzi if you want to give this some "fresh eyes" (namely the |
for more information, see https://pre-commit.ci
2f8ea23
to
7aa86a5
Compare
This PR primarily converts the SQLA Migrations tests from using
AiidaTestCase
to using pytest fixtures, and splits them out into multiple files (to improve readability).The tests are functionally equivalent, just restructured and with a reduction in duplication when using
sqlalchemy.Session
contexts (hence the reduction in lines).One more test has been added (
tests/backends/aiida_sqlalchemy/migrations/test_all_basic.py
), to cycle though all migration versions and try migrating them down&up from&to the latest revision (against an empty database). The list of versions is dynamically generated, to ensure none are missed.To ensure a fully empty database, an option has been added to the test manager
aiida_profile.reset_db(with_user=False)
(defaults toTrue
), whereby the default User will not be auto-generated. This was required for some migrations to succeed when migratingdown
thenup
, and was how the current unittest implementation worked.Note this was actually done in a seperate PR in the end
Also fixes sqlalchemy v2 deprecation: https://docs.sqlalchemy.org/en/14/orm/extensions/automap.html?highlight=prepare#sqlalchemy.ext.automap.AutomapBase.prepare.params.autoload_with
This is a precursor to #5097