2026-02-19 19:05:01 +00:00
|
|
|
import sys
|
|
|
|
|
from pathlib import Path
|
|
|
|
|
from unittest.mock import MagicMock
|
|
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
from fastapi.testclient import TestClient
|
|
|
|
|
|
2026-02-21 16:53:16 +00:00
|
|
|
# ── Stub heavy optional dependencies so tests run without them installed ──────
|
|
|
|
|
# Uses setdefault: real module is used if already installed, mock otherwise.
|
2026-02-19 19:05:01 +00:00
|
|
|
for _mod in [
|
|
|
|
|
"agno",
|
|
|
|
|
"agno.agent",
|
|
|
|
|
"agno.models",
|
|
|
|
|
"agno.models.ollama",
|
|
|
|
|
"agno.db",
|
|
|
|
|
"agno.db.sqlite",
|
2026-02-21 16:53:16 +00:00
|
|
|
# AirLLM is optional (bigbrain extra) — stub it so backend tests can
|
|
|
|
|
# import timmy.backends and instantiate TimmyAirLLMAgent without a GPU.
|
|
|
|
|
"airllm",
|
2026-02-19 19:05:01 +00:00
|
|
|
]:
|
|
|
|
|
sys.modules.setdefault(_mod, MagicMock())
|
|
|
|
|
|
|
|
|
|
|
2026-02-20 14:00:16 +00:00
|
|
|
@pytest.fixture(autouse=True)
|
|
|
|
|
def reset_message_log():
|
|
|
|
|
"""Clear the in-memory chat log before and after every test."""
|
|
|
|
|
from dashboard.store import message_log
|
|
|
|
|
message_log.clear()
|
|
|
|
|
yield
|
|
|
|
|
message_log.clear()
|
|
|
|
|
|
|
|
|
|
|
2026-02-19 19:05:01 +00:00
|
|
|
@pytest.fixture
|
|
|
|
|
def client():
|
|
|
|
|
from dashboard.app import app
|
|
|
|
|
with TestClient(app) as c:
|
|
|
|
|
yield c
|