o2o-castad-backend/app/home/tests/test_db.py

31 lines
904 B
Python

import pytest
from sqlalchemy import text
from app.database.session import AsyncSessionLocal, engine
@pytest.mark.asyncio
async def test_database_connection():
"""데이터베이스 연결 테스트"""
async with engine.begin() as connection:
result = await connection.execute(text("SELECT 1"))
assert result.scalar() == 1
@pytest.mark.asyncio
async def test_session_creation():
"""세션 생성 테스트"""
async with AsyncSessionLocal() as session:
result = await session.execute(text("SELECT 1"))
assert result.scalar() == 1
@pytest.mark.asyncio
async def test_database_version():
"""MySQL 버전 확인 테스트"""
async with AsyncSessionLocal() as session:
result = await session.execute(text("SELECT VERSION()"))
version = result.scalar()
assert version is not None
print(f"MySQL Version: {version}")