Frontend (items 1-10):
- WebSocket streaming integration with useWebSocket hook
- Admin Dashboard UI (status, voices, agents, governance tabs)
- Voice playback UI (TTS/STT integration)
- Settings/Preferences page (conversation style, sliders)
- Responsive/mobile layout (breakpoints at 480px, 768px)
- Dark/light theme with CSS variables and localStorage
- Error handling & loading states (retry, empty state, disabled input)
- Authentication UI (login page, Bearer token, logout)
- Head visualization improvements (active/speaking states, animations)
- Consequence/Ethics dashboard (lessons, consequences, insights tabs)
Backend stubs (items 11-21):
- Tool connectors: DocsConnector (text/md/PDF), DBConnector (SQLite/Postgres), CodeRunnerConnector (Python/JS/Bash/Ruby sandboxed)
- STT adapter: WhisperSTTAdapter, AzureSTTAdapter
- Multi-modal interface adapters: Visual, Haptic, Gesture, Biometric
- SSE streaming endpoint (/v1/sessions/{id}/stream/sse)
- Multi-tenant support (X-Tenant-ID header, tenant CRUD)
- Plugin marketplace/registry (register, install, list)
- Backup/restore endpoints
- Versioned API negotiation (Accept-Version header, deprecation)
Infrastructure (items 22-26):
- docker-compose.yml (API + Postgres + Redis + frontend)
- .env.example with all configurable vars
- gunicorn.conf.py production ASGI config
- Prometheus metrics collector and /metrics endpoint
- Structured JSON logging configuration
Documentation (items 27-29):
- Architecture docs with module layout and subsystem descriptions
- Quickstart guide with setup, API tour, and test instructions
Tests (items 30-32):
- Integration tests: 25 end-to-end API tests
- Frontend tests: 10 Vitest tests for hooks (useTheme, useAuth)
- Load/performance tests: latency and throughput benchmarks
- Connector tests: 16 tests for Docs, DB, CodeRunner
- Multi-modal adapter tests: 9 tests
- Metrics collector tests: 5 tests
- STT adapter tests: 2 tests
511 Python tests passing, 10 frontend tests passing, 0 ruff errors.
Co-Authored-By: Nakamoto, S <defi@defi-oracle.io>
104 lines
4.1 KiB
Python
104 lines
4.1 KiB
Python
"""Tests for tool connectors: Docs, DB, CodeRunner."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from fusionagi.tools.connectors.code_runner import CodeRunnerConnector
|
|
from fusionagi.tools.connectors.db import DBConnector
|
|
from fusionagi.tools.connectors.docs import DocsConnector
|
|
|
|
|
|
class TestDocsConnector:
|
|
def test_read_text_file(self, tmp_path: Path) -> None:
|
|
(tmp_path / "test.txt").write_text("hello world")
|
|
conn = DocsConnector(base_path=str(tmp_path))
|
|
result = conn.invoke("read", {"path": "test.txt"})
|
|
assert result["content"] == "hello world"
|
|
assert result["error"] is None
|
|
|
|
def test_read_missing_file(self, tmp_path: Path) -> None:
|
|
conn = DocsConnector(base_path=str(tmp_path))
|
|
result = conn.invoke("read", {"path": "missing.txt"})
|
|
assert result["error"] is not None
|
|
|
|
def test_search(self, tmp_path: Path) -> None:
|
|
(tmp_path / "a.txt").write_text("foo bar baz")
|
|
(tmp_path / "b.txt").write_text("no match here")
|
|
conn = DocsConnector(base_path=str(tmp_path))
|
|
result = conn.invoke("search", {"query": "bar", "path": "."})
|
|
assert len(result["results"]) == 1
|
|
|
|
def test_list_files(self, tmp_path: Path) -> None:
|
|
(tmp_path / "a.txt").write_text("x")
|
|
(tmp_path / "b.md").write_text("y")
|
|
conn = DocsConnector(base_path=str(tmp_path))
|
|
result = conn.invoke("list", {"path": ".", "pattern": "*"})
|
|
assert len(result["files"]) == 2
|
|
|
|
def test_schema(self) -> None:
|
|
conn = DocsConnector()
|
|
s = conn.schema()
|
|
assert s["name"] == "docs"
|
|
assert "read" in s["actions"]
|
|
|
|
|
|
class TestDBConnector:
|
|
def test_sqlite_crud(self) -> None:
|
|
conn = DBConnector(connection_string=":memory:", driver="sqlite", allow_write=True)
|
|
conn.invoke("execute", {"query": "CREATE TABLE t (id INTEGER, name TEXT)"})
|
|
conn.invoke("execute", {"query": "INSERT INTO t VALUES (1, 'alice')"})
|
|
result = conn.invoke("query", {"query": "SELECT * FROM t"})
|
|
assert result["count"] == 1
|
|
assert result["rows"][0]["name"] == "alice"
|
|
|
|
def test_list_tables(self) -> None:
|
|
conn = DBConnector(connection_string=":memory:", driver="sqlite", allow_write=True)
|
|
conn.invoke("execute", {"query": "CREATE TABLE demo (id INTEGER)"})
|
|
result = conn.invoke("tables", {})
|
|
assert any(r.get("name") == "demo" for r in result["rows"])
|
|
|
|
def test_read_only_blocks_write(self) -> None:
|
|
conn = DBConnector(connection_string=":memory:", driver="sqlite", allow_write=False)
|
|
result = conn.invoke("execute", {"query": "CREATE TABLE t (id INTEGER)"})
|
|
assert "error" in result or "disallowed" in str(result.get("error", ""))
|
|
|
|
def test_schema(self) -> None:
|
|
conn = DBConnector()
|
|
s = conn.schema()
|
|
assert s["name"] == "db"
|
|
|
|
|
|
class TestCodeRunnerConnector:
|
|
def test_run_python(self) -> None:
|
|
conn = CodeRunnerConnector(timeout=10.0)
|
|
result = conn.invoke("run", {"code": "print('hello')", "language": "python"})
|
|
assert result["exit_code"] == 0
|
|
assert "hello" in result["stdout"]
|
|
|
|
def test_run_empty_code(self) -> None:
|
|
conn = CodeRunnerConnector()
|
|
result = conn.invoke("run", {"code": "", "language": "python"})
|
|
assert result["error"] == "Empty code"
|
|
|
|
def test_unsupported_language(self) -> None:
|
|
conn = CodeRunnerConnector()
|
|
result = conn.invoke("run", {"code": "x", "language": "cobol"})
|
|
assert result["error"] is not None
|
|
assert "Unsupported" in str(result["error"])
|
|
|
|
def test_timeout(self) -> None:
|
|
conn = CodeRunnerConnector(timeout=1.0)
|
|
result = conn.invoke("run", {"code": "import time; time.sleep(10)", "language": "python", "timeout": 1.0})
|
|
assert result["error"] == "timeout"
|
|
|
|
def test_list_languages(self) -> None:
|
|
conn = CodeRunnerConnector()
|
|
result = conn.invoke("languages", {})
|
|
assert "python" in result["languages"]
|
|
|
|
def test_schema(self) -> None:
|
|
conn = CodeRunnerConnector()
|
|
s = conn.schema()
|
|
assert s["name"] == "code_runner"
|