Files
wild-pc/castle-api/tests/conftest.py
Paul Payne 930bc601b7 feat: add ComponentGrid and ComponentTable components for displaying components in grid and table formats
feat: implement HealthBadge and RoleBadge components for displaying health status and roles

feat: create LogViewer component for streaming logs of services

feat: develop SecretsEditor for managing secrets with CRUD operations

feat: introduce ToolCard component for displaying tool information

style: add global CSS variables and styles for consistent theming

feat: set up API client for handling requests to the backend

feat: implement hooks for fetching components, statuses, and tools

feat: create routes for dashboard, component details, and tools

feat: add service management endpoints for starting, stopping, and restarting services

feat: implement event bus for handling real-time updates via SSE

feat: create health check and logs endpoints for monitoring services

feat: add tests for health and tools endpoints to ensure functionality

chore: update project configuration files and dependencies for better development experience
2026-02-21 01:23:37 -08:00

67 lines
2.0 KiB
Python

"""Test fixtures for castle-api."""
from collections.abc import Generator
from pathlib import Path
import pytest
import yaml
from fastapi.testclient import TestClient
from castle_api.config import settings
from castle_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"}},
"tool": {
"source": "tools/document",
"system_dependencies": ["pandoc"],
},
},
"test-tool-2": {
"description": "Another test tool",
"tool": {
"source": "tools/utility",
"version": "2.0.0",
},
},
},
}
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