Spaces:
Configuration error
Configuration error
File size: 1,474 Bytes
a6e11a5 ac98b25 a6e11a5 | 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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | """
Shared pytest fixtures for agentcache test suite.
"""
import pytest
import agentcache.app as app_mod
from agentcache.app import create_app
from agentcache.db import StateKV
@pytest.fixture
def tmp_db(tmp_path):
"""Return a fresh StateKV instance backed by a temporary SQLite file."""
db_path = str(tmp_path / "test_store.db")
return StateKV(db_path=db_path)
@pytest.fixture
def app_client(tmp_path, monkeypatch):
"""
Reset all agentcache.app module-level globals, set AGENTCACHE_DB_PATH to a temp db,
and yield a Flask test client.
"""
db_path = str(tmp_path / "app_client.db")
monkeypatch.setenv("AGENTCACHE_DB_PATH", db_path)
app_mod.kv = None
app_mod.search_service = None
app_mod.observation_store = None
app = create_app()
with app.test_client() as client:
yield client
@pytest.fixture
def authed_client(tmp_path, monkeypatch):
"""
Reset all agentcache.app module-level globals, set AGENTCACHE_SECRET=test-secret
and AGENTCACHE_DB_PATH to a temp db, call create_app(), and yield (client, "test-secret").
"""
db_path = str(tmp_path / "authed_client.db")
secret = "test-secret"
monkeypatch.setenv("AGENTCACHE_DB_PATH", db_path)
monkeypatch.setenv("AGENTCACHE_SECRET", secret)
app_mod.kv = None
app_mod.search_service = None
app_mod.observation_store = None
app = create_app()
with app.test_client() as client:
yield client, secret
|