mirror of
https://github.com/basicmachines-co/basic-memory
synced 2026-06-21 13:47:35 +00:00
33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
"""Tests for knowledge graph API routes."""
|
|
|
|
from typing import AsyncGenerator
|
|
|
|
import pytest_asyncio
|
|
from fastapi import FastAPI
|
|
from httpx import AsyncClient, ASGITransport
|
|
|
|
from basic_memory.deps import get_project_config, get_engine_factory
|
|
|
|
|
|
@pytest_asyncio.fixture
|
|
def app(test_config, engine_factory) -> FastAPI:
|
|
"""Create FastAPI test application."""
|
|
# Lazy import router to avoid app startup issues
|
|
from basic_memory.api.routers.knowledge import router as knowledge_router
|
|
from basic_memory.api.routers.documents import router as documents_router
|
|
|
|
app = FastAPI()
|
|
app.include_router(knowledge_router)
|
|
app.include_router(documents_router)
|
|
|
|
app.dependency_overrides[get_project_config] = lambda: test_config
|
|
app.dependency_overrides[get_engine_factory] = lambda: engine_factory
|
|
return app
|
|
|
|
|
|
@pytest_asyncio.fixture
|
|
async def client(app: FastAPI) -> AsyncGenerator[AsyncClient, None]:
|
|
"""Create client using ASGI transport - same as CLI will use."""
|
|
async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client:
|
|
yield client
|