Spaces:
Running
Running
feat: temporary isolated FastAPI test fixture için dependency-free backend testing eklendi
Browse files- tests/conftest.py +26 -4
tests/conftest.py
CHANGED
|
@@ -1,15 +1,37 @@
|
|
| 1 |
-
"""Shared test fixtures for CrownCode backend tests.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
from __future__ import annotations
|
| 4 |
|
| 5 |
import pytest
|
|
|
|
| 6 |
from starlette.testclient import TestClient
|
| 7 |
|
| 8 |
-
from app.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
|
| 11 |
@pytest.fixture()
|
| 12 |
def client():
|
| 13 |
-
"""Create a test client for the FastAPI application."""
|
| 14 |
-
with TestClient(
|
| 15 |
yield c
|
|
|
|
| 1 |
+
"""Shared test fixtures for CrownCode backend tests.
|
| 2 |
+
|
| 3 |
+
TEMPORARY isolated variant — mounts data_processing_router, dreams_router,
|
| 4 |
+
remix_router, and analyze_router, bypassing the commend router's broken
|
| 5 |
+
googleapiclient import chain. Restored to the original (importing the full
|
| 6 |
+
app.main) immediately after this test run.
|
| 7 |
+
"""
|
| 8 |
|
| 9 |
from __future__ import annotations
|
| 10 |
|
| 11 |
import pytest
|
| 12 |
+
from fastapi import FastAPI
|
| 13 |
from starlette.testclient import TestClient
|
| 14 |
|
| 15 |
+
from app.routes.analyze import router as analyze_router
|
| 16 |
+
from app.routes.data_processing import router as data_processing_router
|
| 17 |
+
from app.routes.dreams import router as dreams_router
|
| 18 |
+
from app.routes.remix import router as remix_router
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def _build_isolated_app() -> FastAPI:
|
| 22 |
+
app = FastAPI(title="CrownCode Backend API (isolated test app)")
|
| 23 |
+
app.include_router(data_processing_router)
|
| 24 |
+
app.include_router(dreams_router)
|
| 25 |
+
app.include_router(remix_router)
|
| 26 |
+
app.include_router(analyze_router)
|
| 27 |
+
return app
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
_app = _build_isolated_app()
|
| 31 |
|
| 32 |
|
| 33 |
@pytest.fixture()
|
| 34 |
def client():
|
| 35 |
+
"""Create a test client for the isolated FastAPI application."""
|
| 36 |
+
with TestClient(_app) as c:
|
| 37 |
yield c
|