Skip to content

Fix lint errors on conftest #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from collections.abc import AsyncGenerator
from collections.abc import AsyncGenerator, Generator
from unittest.mock import AsyncMock

import pytest
import pytest_asyncio
from fastapi import FastAPI
from httpx import ASGITransport, AsyncClient
from sqlalchemy.ext.asyncio import AsyncEngine
from sqlalchemy.orm import sessionmaker
from sqlmodel import SQLModel, create_engine
from sqlalchemy.ext.asyncio import async_sessionmaker, create_async_engine
from sqlmodel import SQLModel
from sqlmodel.ext.asyncio.session import AsyncSession

from app.main import app as fastapi_app
Expand All @@ -21,12 +20,10 @@
# Isso garante que os testes são isolados e usam o banco de dados em memória.
TEST_DATABASE_URL = "sqlite+aiosqlite:///:memory:"

test_engine: AsyncEngine = AsyncEngine(
create_engine(TEST_DATABASE_URL, echo=False, future=True)
)
test_engine = create_async_engine(TEST_DATABASE_URL, echo=False, future=True)

# Fábrica de sessões para os testes
TestSessionLocal = sessionmaker(
TestSessionLocal = async_sessionmaker(
test_engine, class_=AsyncSession, expire_on_commit=False
)

Expand Down Expand Up @@ -54,7 +51,7 @@ async def session() -> AsyncGenerator[AsyncSession, None]:


@pytest.fixture
def test_app() -> FastAPI:
def test_app() -> Generator[FastAPI]:
# Create a mock schema checker
mock_schema_checker = AsyncMock()
mock_schema_checker.validate = AsyncMock(return_value=None)
Expand Down