MediBot / tests /conftest.py
bnewcomer's picture
Multi-agent updates
18bfaa1
Raw History Blame Contribute Delete
889 Bytes
import importlib.util
import os
import sys
from pathlib import Path
import pytest
ROOT = Path(__file__).resolve().parents[1]
def _load_app_module():
os.environ.setdefault("OPENAI_API_KEY", "test-key")
if str(ROOT) not in sys.path:
sys.path.insert(0, str(ROOT))
spec = importlib.util.spec_from_file_location("medibot_app", ROOT / "app.py")
module = importlib.util.module_from_spec(spec)
assert spec.loader is not None
spec.loader.exec_module(module)
return module
@pytest.fixture(scope="session")
def app_module():
return _load_app_module()
@pytest.fixture
def medibot_app(app_module, monkeypatch):
app = app_module.MedicalChatbotApp()
monkeypatch.setattr(
app.agents["disease_diagnosis"].reranker,
"rerank",
lambda user_symptoms, candidates, collapsed_df, top_k=5: candidates[:top_k],
)
return app