Next-level improvements: 15 items across backend, frontend, and testing
Backend: - SQLiteStateBackend: persistent task/trace storage with SQLite - InMemoryStateBackend: in-memory impl of StateBackend interface - Redis cache backend (CacheBackend ABC + MemoryCacheBackend + RedisCacheBackend) - OpenAI adapter: async acomplete() with retry logic - Per-tenant + per-IP rate limiting in middleware Frontend: - State management: useStore + useAppState (zero-dep, context + reducer) - React Router integration: URL-based navigation (usePageNavigation) - WebSocket streaming: sendPrompt + StreamCallbacks for token-by-token updates - File preview: inline image/text/binary preview with expand/collapse - Sparkline charts + MetricCard + BarChart for dashboard visualization - Push notifications hook (useNotifications) with browser Notification API - i18n system: 6 locales (en, es, fr, de, ja, zh) with interpolation - 6 new Storybook stories (ChatMessage, Skeleton, Markdown, SearchFilter, Toast, FilePreview) Testing: - Playwright E2E config + 6 browser specs (desktop + mobile) - 18 new Python tests (SQLiteStateBackend, InMemoryStateBackend, cache backends) 570 Python tests + 45 frontend tests = 615 total, 0 ruff errors. Co-Authored-By: Nakamoto, S <defi@defi-oracle.io>
This commit is contained in:
42
tests/test_memory_backend.py
Normal file
42
tests/test_memory_backend.py
Normal file
@@ -0,0 +1,42 @@
|
||||
"""Tests for InMemoryStateBackend."""
|
||||
|
||||
from fusionagi.core.memory_backend import InMemoryStateBackend
|
||||
from fusionagi.schemas.task import Task, TaskState
|
||||
|
||||
|
||||
def test_set_and_get():
|
||||
backend = InMemoryStateBackend()
|
||||
task = Task(task_id="m1", goal="memory test")
|
||||
backend.set_task(task)
|
||||
assert backend.get_task("m1") is not None
|
||||
assert backend.get_task("m1").goal == "memory test"
|
||||
|
||||
|
||||
def test_state_management():
|
||||
backend = InMemoryStateBackend()
|
||||
backend.set_task(Task(task_id="m2", goal="state"))
|
||||
backend.set_task_state("m2", TaskState.ACTIVE)
|
||||
assert backend.get_task_state("m2") == TaskState.ACTIVE
|
||||
|
||||
|
||||
def test_traces():
|
||||
backend = InMemoryStateBackend()
|
||||
backend.set_task(Task(task_id="m3", goal="traces"))
|
||||
backend.append_trace("m3", {"a": 1})
|
||||
backend.append_trace("m3", {"b": 2})
|
||||
assert len(backend.get_trace("m3")) == 2
|
||||
|
||||
|
||||
def test_delete():
|
||||
backend = InMemoryStateBackend()
|
||||
backend.set_task(Task(task_id="m4", goal="del"))
|
||||
assert backend.delete_task("m4") is True
|
||||
assert backend.delete_task("m4") is False
|
||||
|
||||
|
||||
def test_list_and_count():
|
||||
backend = InMemoryStateBackend()
|
||||
for i in range(3):
|
||||
backend.set_task(Task(task_id=f"l{i}", goal=f"g{i}"))
|
||||
assert backend.count_tasks() == 3
|
||||
assert len(backend.list_tasks()) == 3
|
||||
Reference in New Issue
Block a user