Set up mongo connection in pytest & fix authentication url

This commit is contained in:
stijndcl 2022-07-25 21:08:06 +02:00
parent 52b452c85a
commit 6bebd109bb
2 changed files with 17 additions and 4 deletions

View file

@ -7,14 +7,14 @@ from sqlalchemy.orm import sessionmaker
import settings
encoded_password = quote_plus(settings.POSTGRES_PASS)
encoded_postgres_password = quote_plus(settings.POSTGRES_PASS)
# PostgreSQL engine
postgres_engine = create_async_engine(
URL.create(
drivername="postgresql+asyncpg",
username=settings.POSTGRES_USER,
password=encoded_password,
password=encoded_postgres_password,
host=settings.POSTGRES_HOST,
port=settings.POSTGRES_PORT,
database=settings.POSTGRES_DB,
@ -28,4 +28,7 @@ DBSession = sessionmaker(
)
# MongoDB client
mongo_client = motor.motor_asyncio.AsyncIOMotorClient(settings.MONGO_HOST, settings.MONGO_PORT)
encoded_mongo_username = quote_plus(settings.MONGO_USER)
encoded_mongo_password = quote_plus(settings.MONGO_PASS)
mongo_url = f"mongodb://{encoded_mongo_username}:{encoded_mongo_password}@{settings.MONGO_HOST}:{settings.MONGO_PORT}/"
mongo_client = motor.motor_asyncio.AsyncIOMotorClient(mongo_url)