The database utility currently runs a database check that will cause the entire app to fail to load if there is not database connection. This is intentional. However, having that check run in top-level code makes it more complicated to mock the database in other modules. Instead, we should put that initialization/check code into a function that is called by the main script. Then it will no longer be necessary to load other modules dynamically to avoid grabbing the wrong database object.
This could possibly be done alongside #1756.
Acceptance criteria
[ ] Database initialization and checking are wrapped in a function
[ ] The main script calls the init/check function
[ ] Database tests are updated accordingly
[ ] Module tests that dynamically import their modules because of the top-level database function are modified to use static imports
Description
The database utility currently runs a database check that will cause the entire app to fail to load if there is not database connection. This is intentional. However, having that check run in top-level code makes it more complicated to mock the database in other modules. Instead, we should put that initialization/check code into a function that is called by the main script. Then it will no longer be necessary to load other modules dynamically to avoid grabbing the wrong database object.
This could possibly be done alongside #1756.
Acceptance criteria