- use Alembic to migrate the PostgreSQL database
+ create initial migration script to set up the database,
as an alternative to db.Base.metadata.create_all()
+ integrate Alembic into the test suite; the db_engine fixture
now has two modes:
* create the latest version of tables all at once
* invoke `alembic upgrade head`
=> the "e2e" tests are all run twice, once in each mode; this
ensures that the migration scripts re-create the same database
schema as db.Base.metadata.create_all() would
* in both modes, a temporary PostgreSQL schema is used to create the
tables in
=> could now run "e2e" tests against production database and still
have isolation
- make the configuration module public (to be used by Alembic)
- adjust linting rules for Alembic
37 lines
934 B
Python
37 lines
934 B
Python
"""Source code for the urban-meal-delivery research project.
|
|
|
|
Example:
|
|
>>> import urban_meal_delivery as umd
|
|
>>> umd.__version__ != '0.0.0'
|
|
True
|
|
"""
|
|
|
|
import os as _os
|
|
from importlib import metadata as _metadata
|
|
|
|
from urban_meal_delivery import configuration as _configuration
|
|
|
|
|
|
try:
|
|
_pkg_info = _metadata.metadata(__name__)
|
|
|
|
except _metadata.PackageNotFoundError: # pragma: no cover
|
|
__author__ = 'unknown'
|
|
__pkg_name__ = 'unknown'
|
|
__version__ = 'unknown'
|
|
|
|
else:
|
|
__author__ = _pkg_info['author']
|
|
__pkg_name__ = _pkg_info['name']
|
|
__version__ = _pkg_info['version']
|
|
|
|
|
|
# Global `config` object to be used in the package.
|
|
config: _configuration.Config = _configuration.make_config(
|
|
'testing' if _os.getenv('TESTING') else 'production',
|
|
)
|
|
|
|
|
|
# Import `db` down here as it depends on `config`.
|
|
# pylint:disable=wrong-import-position
|
|
from urban_meal_delivery import db # noqa:E402,F401 isort:skip
|