How to test DB connection failures mid execution #1338
-
I am upgrading from flask-sqlalchemy 2.5.1 to 3.1.1 and have a test case that used to work but now isn't. The test case looks like:
The route on the app looks like:
What I'm wondering is if people think this is a change with flask-sqalchemy in how it handles updating the config (maybe SqlAlchemy used to reference the config everytime when doing a I recognize that changing the DB URL mid-execution of a flask app isn't something we'd normally do but we're not sure how else to simulate a DB failure outside of putting test paths in production code (which we'd like to avoid). |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I ended up changing my testing strategy. Our code creates a postgresql server in python so we passed a reference up to the test and stopped the server.
and then our test becomes:
|
Beta Was this translation helpful? Give feedback.
I ended up changing my testing strategy. Our code creates a postgresql server in python so we passed a reference up to the test and stopped the server.