Download tests/conftest.py from ArshVerma/CodeLens: direct link, hf CLI and curl.
- Browser
- Download file 1.46 kB
-
https://huggingface.co/spaces/ArshVerma/CodeLens/resolve/main/tests/conftest.py
- Command line
-
hf download hf://spaces/ArshVerma/CodeLens/tests/conftest.py
-
curl -L -o conftest.py https://huggingface.co/spaces/ArshVerma/CodeLens/resolve/main/tests/conftest.py
1.46 kB
| import pytest | |
| import os | |
| os.environ["TESTING"] = "true" | |
| os.environ["APP_ENV"] = "test" | |
| os.environ["HF_TOKEN"] = "mock-token" | |
| from fastapi.testclient import TestClient | |
| from sqlmodel import SQLModel, Session, create_engine | |
| from sqlmodel.pool import StaticPool | |
| from app import app | |
| from codelens_env.database import get_session | |
| from codelens_env.env import CodeLensEnv | |
| from codelens_env.models import TaskId, Action, ActionType, Severity, Category, Verdict | |
| def session_fixture(): | |
| """In-memory SQLite session for tests.""" | |
| engine = create_engine( | |
| "sqlite://", | |
| connect_args={"check_same_thread": False}, | |
| poolclass=StaticPool, | |
| ) | |
| SQLModel.metadata.create_all(engine) | |
| with Session(engine) as session: | |
| yield session | |
| def client_fixture(session): | |
| """TestClient with DB dependency override.""" | |
| def get_session_override(): | |
| yield session | |
| app.dependency_overrides[get_session] = get_session_override | |
| client = TestClient(app) | |
| yield client | |
| app.dependency_overrides.clear() | |
| def env(): | |
| return CodeLensEnv() | |
| def approve_action(): | |
| return Action(action_type=ActionType.APPROVE, body="LGTM", verdict=Verdict.LGTM) | |
| def request_changes_action(): | |
| return Action(action_type=ActionType.REQUEST_CHANGES, body="Issues found", | |
| verdict=Verdict.REQUEST_CHANGES) | |