Spaces:
Running
Running
feat: pytest fixture için Starlette test istemci için conftest.py eklendi
Browse files- tests/conftest.py +4 -26
tests/conftest.py
CHANGED
|
@@ -1,37 +1,15 @@
|
|
| 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.
|
| 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
|
| 36 |
-
with TestClient(
|
| 37 |
yield c
|
|
|
|
| 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.main import app
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
|
| 11 |
@pytest.fixture()
|
| 12 |
def client():
|
| 13 |
+
"""Create a test client for the FastAPI application."""
|
| 14 |
+
with TestClient(app) as c:
|
| 15 |
yield c
|