mirror of
https://github.com/stijndcl/didier.git
synced 2026-04-07 23:55:46 +02:00
Set up mongo connection in pytest & fix authentication url
This commit is contained in:
parent
52b452c85a
commit
6bebd109bb
2 changed files with 17 additions and 4 deletions
|
|
@ -2,10 +2,12 @@ import asyncio
|
|||
from typing import AsyncGenerator, Generator
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import motor.motor_asyncio
|
||||
import pytest
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from database.engine import postgres_engine
|
||||
import settings
|
||||
from database.engine import mongo_client, postgres_engine
|
||||
from database.migrations import ensure_latest_migration, migrate
|
||||
from didier import Didier
|
||||
|
||||
|
|
@ -54,6 +56,14 @@ async def postgres(tables) -> AsyncGenerator[AsyncSession, None]:
|
|||
await connection.close()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
async def mongodb() -> motor.motor_asyncio.AsyncIOMotorDatabase:
|
||||
"""Fixture to get a MongoDB connection"""
|
||||
database = mongo_client[settings.MONGO_DB]
|
||||
yield database
|
||||
mongo_client.drop_database(settings.MONGO_DB)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_client() -> Didier:
|
||||
"""Fixture to get a mock Didier instance
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue