-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Mapping tests: restructure, refactor, decouple session and engine, improve #12765
Conversation
It is possible (even likely, with a different/better/simpler session setup) that the objects populating the collection attribute representing a relationship on a stored object will NOT be the same Python objects that were initially associated with the object via that relationship. Thus, Python object identity comparison will fail (when we change the session setup). Besides, we should be using the database primary key as the comparison key, because that is the only correct measure of database-mapped object equality.
Disable test verification fixture by default (too expensive!) Add comment explaining fixture + how to enable it.
Here we are supposed to be testing mapping; however, by using Galaxy's session and engine, we also end up testing session and engine setup (i.e., "testing by coincidence"). Instead, we will use a plain engine and session, thus limiting these tests to their expected scope. Applied to model and install_model mapping tests.
I feel like |
@jmchilton Thanks! That said, I will be adding additional unit tests covering our session and engine setup. I need that for fixing the SQLAlchemy removed-in-2.0 warnings; and also for modifying some of that code for Alembic. |
Summary of changes:
The tests reused the session object defined in galaxy.model (which used an engine built for a functioning Galaxy). With that setup, in addition to testing the mapping, we also unintentionally tested Galaxy's session and engine setup (thus, "testing by coincidence"). Here we create a separate engine and session, ensuring that their setup does not interfere with the test. (see b0c291c)
Note: This was supposed to get rid of code, not add! However, I used black with default settings on
test_model_mapping.py
to get rid of all the long lines that were a result of replacing a simple equality with a call to the new helper function. I don't love the formatting, but I love not having an opinion on how to format 7K lines 😄(I don't mind reformatting it back if needed)
How to test the changes?
(Select all options that apply)
License