mirror of https://github.com/stijndcl/didier
Require no auth for mongo in tests
parent
5f9a57cd83
commit
d4dae7826d
|
@ -49,8 +49,6 @@ jobs:
|
|||
- 27018:27017
|
||||
env:
|
||||
MONGO_DB: didier_pytest
|
||||
MONGO_USER: pytest
|
||||
MONGO_PASSWORD: pytest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup Python
|
||||
|
|
|
@ -28,7 +28,14 @@ DBSession = sessionmaker(
|
|||
)
|
||||
|
||||
# MongoDB client
|
||||
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}/"
|
||||
if not settings.TESTING:
|
||||
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}/"
|
||||
)
|
||||
else:
|
||||
# Require no authentication when testing
|
||||
mongo_url = f"mongodb://{settings.MONGO_HOST}:{settings.MONGO_PORT}/"
|
||||
|
||||
mongo_client = motor.motor_asyncio.AsyncIOMotorClient(mongo_url)
|
||||
|
|
|
@ -14,9 +14,6 @@ services:
|
|||
image: mongo:5.0
|
||||
restart: always
|
||||
environment:
|
||||
- MONGO_INITDB_ROOT_USERNAME=pytest
|
||||
- MONGO_INITDB_ROOT_PASSWORD=pytest
|
||||
- MONGO_INITDB_DATABASE=didier_pytest
|
||||
command: [--auth]
|
||||
ports:
|
||||
- "27018:27017"
|
||||
|
|
|
@ -42,9 +42,8 @@ ignore_missing_imports = true
|
|||
[tool.pytest.ini_options]
|
||||
asyncio_mode = "auto"
|
||||
env = [
|
||||
"TESTING = 1",
|
||||
"MONGO_DB = didier_pytest",
|
||||
"MONGO_USER = pytest",
|
||||
"MONGO_PASS = pytest",
|
||||
"MONGO_HOST = localhost",
|
||||
"MONGO_PORT = 27018",
|
||||
"POSTGRES_DB = didier_pytest",
|
||||
|
|
|
@ -8,6 +8,7 @@ env.read_env()
|
|||
|
||||
__all__ = [
|
||||
"SANDBOX",
|
||||
"TESTING",
|
||||
"LOGFILE",
|
||||
"POSTGRES_DB",
|
||||
"POSTGRES_USER",
|
||||
|
@ -28,6 +29,7 @@ __all__ = [
|
|||
|
||||
"""General config"""
|
||||
SANDBOX: bool = env.bool("SANDBOX", True)
|
||||
TESTING: bool = env.bool("TESTING", False)
|
||||
LOGFILE: str = env.str("LOGFILE", "didier.log")
|
||||
SEMESTER: int = env.int("SEMESTER", 2)
|
||||
YEAR: int = env.int("YEAR", 3)
|
||||
|
|
Loading…
Reference in New Issue