Import velofy.config as pkg_config everywhere

This commit is contained in:
Alexander Hess 2026-11-30 20:19:35 +01:00
commit cf2534f41e
Signed by: alexander
GPG key ID: B46EDB4DFC26805D

View file

@ -12,7 +12,7 @@ from alembic import command as alembic_cmd
from alembic import config as alembic_config
from sqlalchemy import orm
from velofy import config
from velofy import config as pkg_config
from velofy import db
@ -29,7 +29,7 @@ pytest_plugins = [
if not os.getenv("TESTING"):
raise RuntimeError("Tests must be executed with TESTING set in the environment")
if not config.TESTING:
if not pkg_config.TESTING:
raise RuntimeError("The testing configuration was not loaded")
@ -51,12 +51,12 @@ def db_connection(request):
"""
# We need a fresh database connection for each of the two `params`.
# Otherwise, the first test of the parameter run second will fail.
engine = sa.create_engine(config.DATABASE_URI)
engine = sa.create_engine(pkg_config.DATABASE_URI)
connection = engine.connect()
if request.param == "all_at_once":
with connection.begin():
connection.execute(sa.text(f"CREATE SCHEMA {config.CLEAN_SCHEMA};"))
connection.execute(sa.text(f"CREATE SCHEMA {pkg_config.CLEAN_SCHEMA};"))
db.Base.metadata.create_all(connection)
else:
cfg = alembic_config.Config("alembic.ini")
@ -71,13 +71,15 @@ def db_connection(request):
connection.close()
with engine.begin() as cleanup:
cleanup.execute(sa.text(f"DROP SCHEMA {config.CLEAN_SCHEMA} CASCADE;"))
cleanup.execute(sa.text(f"DROP SCHEMA {pkg_config.CLEAN_SCHEMA} CASCADE;"))
if request.param == "sequentially":
tmp_alembic_version = f"{config.ALEMBIC_TABLE}_{config.CLEAN_SCHEMA}"
tmp_alembic_version = (
f"{pkg_config.ALEMBIC_TABLE}_{pkg_config.CLEAN_SCHEMA}"
)
cleanup.execute(
sa.text(
f"DROP TABLE {config.ALEMBIC_TABLE_SCHEMA}.{tmp_alembic_version};", # noqa:E501
f"DROP TABLE {pkg_config.ALEMBIC_TABLE_SCHEMA}.{tmp_alembic_version};", # noqa:E501
),
)