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