Use globals for the database connection
- remove the factory functions for creating engines and sessions - define global engine, connection, and session objects to be used everywhere in the urban_meal_delivery package
This commit is contained in:
parent
f996376b13
commit
2e3ccd14d5
8 changed files with 74 additions and 24 deletions
10
noxfile.py
10
noxfile.py
|
|
@ -254,6 +254,12 @@ def test(session):
|
|||
|
||||
# For xdoctest, the default arguments are different from pytest.
|
||||
args = posargs or [PACKAGE_IMPORT_NAME]
|
||||
|
||||
# The "TESTING" environment variable forces the global `engine`, `connection`,
|
||||
# and `session` objects to be set to `None` and avoid any database connection.
|
||||
# For pytest above this is not necessary as pytest sets this variable itself.
|
||||
session.env['TESTING'] = 'true'
|
||||
|
||||
session.run('xdoctest', '--version')
|
||||
session.run('xdoctest', '--quiet', *args) # --quiet => less verbose output
|
||||
|
||||
|
|
@ -297,6 +303,10 @@ def docs(session):
|
|||
session.run('poetry', 'install', '--no-dev', external=True)
|
||||
_install_packages(session, 'sphinx', 'sphinx-autodoc-typehints')
|
||||
|
||||
# The "TESTING" environment variable forces the global `engine`, `connection`,
|
||||
# and `session` objects to be set to `None` and avoid any database connection.
|
||||
session.env['TESTING'] = 'true'
|
||||
|
||||
session.run('sphinx-build', DOCS_SRC, DOCS_BUILD)
|
||||
# Verify all external links return 200 OK.
|
||||
session.run('sphinx-build', '-b', 'linkcheck', DOCS_SRC, DOCS_BUILD)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue