gradio_demo_CatDogClassifier / tests /test_db_connection.py
Soutrik
added: fastapi framework
36ed17a
raw
history blame
586 Bytes
import pytest
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy import text
from app.db.database import get_db
@pytest.mark.asyncio
async def test_database_connection():
# Use the get_db dependency directly for testing
async for session in get_db():
assert isinstance(
session, AsyncSession
), "Session is not an instance of AsyncSession"
# Check if the session can execute a simple query
result = await session.execute(text("SELECT 1"))
assert result.scalar() == 1, "Database did not return expected result"