feat: Add new tools and configurations for Castle platform

- Introduced `uv.lock` for dependency management with various packages including `pytest`, `colorama`, and `pluggy`.
- Added `pyrightconfig.json` for Python type checking configuration.
- Expanded `recommendations.md` with detailed scaling recommendations and project management strategies.
- Created shared `ruff.toml` for consistent linting across projects.
- Developed `Castle Tools` with various utilities including Android backup, browser automation, document conversion, and search tools.
- Implemented `backup-collect` and `schedule` tools for system administration tasks.
- Enhanced `search` functionality with indexing and querying capabilities using Tantivy.
- Added comprehensive documentation for each tool, including usage examples and installation instructions.
This commit is contained in:
2026-02-20 16:41:19 -08:00
parent 0d35ac9ffd
commit f39a551aad
152 changed files with 21197 additions and 83 deletions

View File

View File

@@ -0,0 +1,55 @@
"""Test fixtures for dashboard-api."""
from collections.abc import Generator
from pathlib import Path
import pytest
import yaml
from fastapi.testclient import TestClient
from dashboard_api.config import settings
from dashboard_api.main import app
@pytest.fixture
def castle_root(tmp_path: Path) -> Generator[Path, None, None]:
"""Create a temporary castle root with castle.yaml."""
castle_yaml = tmp_path / "castle.yaml"
config = {
"gateway": {"port": 9000},
"components": {
"test-svc": {
"description": "Test service",
"run": {
"runner": "python_uv_tool",
"tool": "test-svc",
"cwd": "test-svc",
},
"expose": {
"http": {
"internal": {"port": 19000},
"health_path": "/health",
}
},
"proxy": {"caddy": {"path_prefix": "/test-svc"}},
"manage": {"systemd": {}},
},
"test-tool": {
"description": "Test tool",
"install": {"path": {"alias": "test-tool"}},
},
},
}
castle_yaml.write_text(yaml.dump(config, default_flow_style=False))
original = settings.castle_root
settings.castle_root = tmp_path
yield tmp_path
settings.castle_root = original
@pytest.fixture
def client(castle_root: Path) -> Generator[TestClient, None, None]:
"""Create a test client pointing to temporary castle root."""
with TestClient(app) as client:
yield client

View File

@@ -0,0 +1,77 @@
"""Tests for dashboard-api health endpoint."""
from fastapi.testclient import TestClient
class TestHealth:
"""Health endpoint tests."""
def test_health(self, client: TestClient) -> None:
"""Health endpoint returns ok."""
response = client.get("/health")
assert response.status_code == 200
assert response.json() == {"status": "ok"}
class TestComponents:
"""Component list endpoint tests."""
def test_list_components(self, client: TestClient) -> None:
"""Returns all registered components."""
response = client.get("/components")
assert response.status_code == 200
data = response.json()
names = [c["id"] for c in data]
assert "test-svc" in names
assert "test-tool" in names
def test_service_has_port(self, client: TestClient) -> None:
"""Service component includes port info."""
response = client.get("/components")
data = response.json()
svc = next(c for c in data if c["id"] == "test-svc")
assert svc["port"] == 19000
assert svc["health_path"] == "/health"
assert svc["proxy_path"] == "/test-svc"
assert svc["managed"] is True
assert "service" in svc["roles"]
def test_tool_has_no_port(self, client: TestClient) -> None:
"""Tool component has no port."""
response = client.get("/components")
data = response.json()
tool = next(c for c in data if c["id"] == "test-tool")
assert tool["port"] is None
assert "tool" in tool["roles"]
class TestComponentDetail:
"""Component detail endpoint tests."""
def test_get_component(self, client: TestClient) -> None:
"""Returns detailed info for a component."""
response = client.get("/components/test-svc")
assert response.status_code == 200
data = response.json()
assert data["id"] == "test-svc"
assert "manifest" in data
assert data["manifest"]["run"]["runner"] == "python_uv_tool"
def test_not_found(self, client: TestClient) -> None:
"""Returns 404 for unknown component."""
response = client.get("/components/nonexistent")
assert response.status_code == 404
class TestGateway:
"""Gateway info endpoint tests."""
def test_gateway_info(self, client: TestClient) -> None:
"""Returns gateway configuration."""
response = client.get("/gateway")
assert response.status_code == 200
data = response.json()
assert data["port"] == 9000
assert data["component_count"] == 2
assert data["service_count"] == 1
assert data["managed_count"] == 1