Spaces:
Runtime error
Runtime error
File size: 586 Bytes
36ed17a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
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"
|