Spaces:
Sleeping
Sleeping
File size: 889 Bytes
18bfaa1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | 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
|