From f465fd4bb628fb7da67e51bc3b28dddb6e521be5 Mon Sep 17 00:00:00 2001 From: Wenzhuo Zhao Date: Wed, 14 Feb 2024 13:05:31 +0100 Subject: [PATCH] fix(test): fake test OPENAI_API_KEY --- api/tests/conftest.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/api/tests/conftest.py b/api/tests/conftest.py index 4af38bd..d25cbd1 100644 --- a/api/tests/conftest.py +++ b/api/tests/conftest.py @@ -5,7 +5,6 @@ from sqlalchemy import create_engine, StaticPool from sqlalchemy.orm import sessionmaker from starlette.testclient import TestClient - from api.web.api import api_router @@ -23,9 +22,16 @@ def get_test_app() -> FastAPI: app.state.db_engine = engine app.state.db_session_factory = TestingSessionLocal + + # environment variable OPENAI_API_KEY is required + # to run the tests + app.state.os_environ = {"OPENAI_API_KEY": "fake_key"} + # noqa: F821 app.include_router(router=api_router, prefix="/api") + # set fake environment variable OPENAI_API_KEY to run tests + return app