- 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.
69 lines
1.9 KiB
Python
69 lines
1.9 KiB
Python
"""Shared fixtures for castle CLI tests."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from collections.abc import Generator
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
import yaml
|
|
|
|
|
|
@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": 18000},
|
|
"components": {
|
|
"test-svc": {
|
|
"description": "Test service",
|
|
"run": {
|
|
"runner": "python_uv_tool",
|
|
"tool": "test-svc",
|
|
"cwd": "test-svc",
|
|
"env": {"TEST_SVC_DATA_DIR": str(tmp_path / "data" / "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))
|
|
|
|
# Create project directories
|
|
svc_dir = tmp_path / "test-svc"
|
|
svc_dir.mkdir()
|
|
(svc_dir / "pyproject.toml").write_text("[project]\nname = 'test-svc'\n")
|
|
|
|
tool_dir = tmp_path / "test-tool"
|
|
tool_dir.mkdir()
|
|
|
|
yield tmp_path
|
|
|
|
|
|
@pytest.fixture
|
|
def castle_home(tmp_path: Path) -> Generator[Path, None, None]:
|
|
"""Create a temporary ~/.castle directory."""
|
|
home = tmp_path / ".castle"
|
|
home.mkdir()
|
|
(home / "generated").mkdir()
|
|
(home / "secrets").mkdir()
|
|
yield home
|