mirror of
https://github.com/stijndcl/didier.git
synced 2026-04-07 15:48:29 +02:00
Add test container
This commit is contained in:
parent
ca9dd84ab5
commit
5f2e26f154
5 changed files with 27 additions and 35 deletions
|
|
@ -6,27 +6,17 @@ from sqlalchemy.orm import sessionmaker
|
|||
|
||||
import settings
|
||||
|
||||
# Run local tests against SQLite instead of Postgres
|
||||
if settings.TESTING and settings.DB_TEST_SQLITE:
|
||||
engine = create_async_engine(
|
||||
URL.create(
|
||||
drivername="sqlite+aiosqlite",
|
||||
database="tests.db",
|
||||
),
|
||||
connect_args={"check_same_thread": False},
|
||||
)
|
||||
else:
|
||||
encoded_password = quote_plus(settings.DB_PASSWORD)
|
||||
engine = create_async_engine(
|
||||
URL.create(
|
||||
drivername="postgresql+asyncpg",
|
||||
username=settings.DB_USERNAME,
|
||||
password=encoded_password,
|
||||
host=settings.DB_HOST,
|
||||
port=settings.DB_PORT,
|
||||
database=settings.DB_NAME,
|
||||
),
|
||||
pool_pre_ping=True,
|
||||
)
|
||||
encoded_password = quote_plus(settings.DB_PASSWORD)
|
||||
engine = create_async_engine(
|
||||
URL.create(
|
||||
drivername="postgresql+asyncpg",
|
||||
username=settings.DB_USERNAME,
|
||||
password=encoded_password,
|
||||
host=settings.DB_HOST,
|
||||
port=settings.DB_PORT,
|
||||
database=settings.DB_NAME,
|
||||
),
|
||||
pool_pre_ping=True,
|
||||
)
|
||||
|
||||
DBSession = sessionmaker(autocommit=False, autoflush=False, bind=engine, class_=AsyncSession, expire_on_commit=False)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue