diff --git a/backend/app/tests/api/routes/collections/test_collection_info.py b/backend/app/tests/api/routes/collections/test_collection_info.py index 26e7ef91..762a6654 100644 --- a/backend/app/tests/api/routes/collections/test_collection_info.py +++ b/backend/app/tests/api/routes/collections/test_collection_info.py @@ -1,26 +1,15 @@ -import pytest from uuid import uuid4 from datetime import datetime, timezone from fastapi.testclient import TestClient from sqlmodel import Session from app.core.config import settings from app.models import Collection -from app.crud.collection import CollectionCrud from app.main import app from app.tests.utils.utils import get_user_from_api_key -from app.seed_data.seed_data import seed_database from app.models.collection import CollectionStatus client = TestClient(app) - -@pytest.fixture(scope="function", autouse=True) -def load_seed_data(db): - """Load seed data before each test.""" - seed_database(db) - yield - - original_api_key = "ApiKey No3x47A5qoIGhm0kVKjQ77dhCqEdWRIQZlEPzzzh7i8" diff --git a/backend/app/tests/api/routes/collections/test_create_collections.py b/backend/app/tests/api/routes/collections/test_create_collections.py index 6fb0855c..2a97fb45 100644 --- a/backend/app/tests/api/routes/collections/test_create_collections.py +++ b/backend/app/tests/api/routes/collections/test_create_collections.py @@ -3,29 +3,19 @@ import io import openai_responses -from sqlmodel import Session, select +from sqlmodel import Session from fastapi.testclient import TestClient -from openai import OpenAIError from app.core.config import settings from app.tests.utils.document import DocumentStore from app.tests.utils.utils import openai_credentials, get_user_from_api_key from app.main import app from app.crud.collection import CollectionCrud -from app.api.routes.collections import CreationRequest, ResponsePayload -from app.seed_data.seed_data import seed_database from app.models.collection import CollectionStatus client = TestClient(app) -@pytest.fixture(scope="function", autouse=True) -def load_seed_data(db): - """Load seed data before each test.""" - seed_database(db) - yield - - @pytest.fixture(autouse=True) def mock_s3(monkeypatch): class FakeStorage: diff --git a/backend/app/tests/api/routes/test_responses.py b/backend/app/tests/api/routes/test_responses.py index 049b6dba..e24b7a4d 100644 --- a/backend/app/tests/api/routes/test_responses.py +++ b/backend/app/tests/api/routes/test_responses.py @@ -6,7 +6,6 @@ from app.api.routes.responses import router from app.models import Project -from app.seed_data.seed_data import seed_database # Wrap the router in a FastAPI app instance app = FastAPI() @@ -14,14 +13,6 @@ client = TestClient(app) -@pytest.fixture(scope="function", autouse=True) -def load_seed_data(db): - """Load seed data before each test.""" - seed_database(db) - yield - # Cleanup is handled by the db fixture in conftest.py - - @patch("app.api.routes.responses.OpenAI") @patch("app.api.routes.responses.get_provider_credential") def test_responses_endpoint_success( diff --git a/backend/app/tests/conftest.py b/backend/app/tests/conftest.py index e2a6464d..9f6fe76c 100644 --- a/backend/app/tests/conftest.py +++ b/backend/app/tests/conftest.py @@ -20,6 +20,7 @@ ) from app.tests.utils.user import authentication_token_from_email from app.tests.utils.utils import get_superuser_token_headers +from app.seed_data.seed_data import seed_database @pytest.fixture(scope="session", autouse=True) @@ -56,3 +57,9 @@ def normal_user_token_headers(client: TestClient, db: Session) -> dict[str, str] return authentication_token_from_email( client=client, email=settings.EMAIL_TEST_USER, db=db ) + + +@pytest.fixture(scope="session", autouse=True) +def load_seed_data(db): + seed_database(db) + yield