Skip to content
Merged
Show file tree
Hide file tree
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
11 changes: 0 additions & 11 deletions backend/app/tests/api/routes/collections/test_collection_info.py
Original file line number Diff line number Diff line change
@@ -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"


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 0 additions & 9 deletions backend/app/tests/api/routes/test_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,13 @@

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()
app.include_router(router)
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(
Expand Down
7 changes: 7 additions & 0 deletions backend/app/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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