2026-03-05 21:54:24 -05:00
|
|
|
import shutil
|
2026-03-08 12:50:44 -04:00
|
|
|
import subprocess
|
2026-03-05 21:54:24 -05:00
|
|
|
from pathlib import Path
|
|
|
|
|
|
2026-03-08 12:50:44 -04:00
|
|
|
import pytest
|
|
|
|
|
|
2026-03-05 21:54:24 -05:00
|
|
|
# Constants for testing
|
|
|
|
|
TEST_PROJECT_DIR = Path("/home/ubuntu/test-sovereign-stack")
|
|
|
|
|
TEST_VAULT_DIR = TEST_PROJECT_DIR / "TimmyVault"
|
|
|
|
|
SETUP_SCRIPT_PATH = Path("/home/ubuntu/setup_timmy.sh")
|
|
|
|
|
|
2026-03-06 13:21:05 -05:00
|
|
|
pytestmark = pytest.mark.skipif(
|
|
|
|
|
not SETUP_SCRIPT_PATH.exists(),
|
|
|
|
|
reason=f"Setup script not found at {SETUP_SCRIPT_PATH}",
|
|
|
|
|
)
|
|
|
|
|
|
2026-03-08 12:50:44 -04:00
|
|
|
|
2026-03-05 21:54:24 -05:00
|
|
|
@pytest.fixture(scope="module", autouse=True)
|
|
|
|
|
def cleanup_test_env():
|
|
|
|
|
"""Ensure a clean environment before and after tests."""
|
|
|
|
|
if TEST_PROJECT_DIR.exists():
|
|
|
|
|
shutil.rmtree(TEST_PROJECT_DIR)
|
|
|
|
|
yield
|
|
|
|
|
# We keep the test env for manual inspection if needed, or cleanup
|
|
|
|
|
# shutil.rmtree(TEST_PROJECT_DIR)
|
|
|
|
|
|
2026-03-08 12:50:44 -04:00
|
|
|
|
2026-03-05 21:54:24 -05:00
|
|
|
def run_setup_command(args):
|
|
|
|
|
"""Helper to run the setup script with arguments."""
|
|
|
|
|
result = subprocess.run(
|
2026-03-08 12:50:44 -04:00
|
|
|
[str(SETUP_SCRIPT_PATH)] + args, capture_output=True, text=True, cwd="/home/ubuntu"
|
2026-03-05 21:54:24 -05:00
|
|
|
)
|
|
|
|
|
return result
|
|
|
|
|
|
2026-03-08 12:50:44 -04:00
|
|
|
|
2026-03-05 21:54:24 -05:00
|
|
|
def test_setup_install_creates_directories():
|
|
|
|
|
"""Test that './setup_timmy.sh install' creates the expected directory structure."""
|
|
|
|
|
# Note: We expect the script to be present at SETUP_SCRIPT_PATH
|
|
|
|
|
assert SETUP_SCRIPT_PATH.exists(), "Setup script must exist before testing"
|
2026-03-08 12:50:44 -04:00
|
|
|
|
2026-03-05 21:54:24 -05:00
|
|
|
result = run_setup_command(["install"])
|
2026-03-08 12:50:44 -04:00
|
|
|
|
2026-03-05 21:54:24 -05:00
|
|
|
# Check if command succeeded
|
|
|
|
|
assert result.returncode == 0, f"Setup install failed: {result.stderr}"
|
2026-03-08 12:50:44 -04:00
|
|
|
|
2026-03-05 21:54:24 -05:00
|
|
|
# Check directory structure
|
|
|
|
|
assert TEST_PROJECT_DIR.exists()
|
|
|
|
|
assert (TEST_PROJECT_DIR / "paperclip").exists()
|
|
|
|
|
assert (TEST_PROJECT_DIR / "agents/hello-timmy").exists()
|
|
|
|
|
assert TEST_VAULT_DIR.exists()
|
|
|
|
|
assert (TEST_PROJECT_DIR / "logs").exists()
|
|
|
|
|
|
2026-03-08 12:50:44 -04:00
|
|
|
|
2026-03-05 21:54:24 -05:00
|
|
|
def test_setup_install_creates_files():
|
|
|
|
|
"""Test that './setup_timmy.sh install' creates the expected configuration and notes."""
|
|
|
|
|
# Check Agent config
|
|
|
|
|
agent_toml = TEST_PROJECT_DIR / "agents/hello-timmy/agent.toml"
|
|
|
|
|
assert agent_toml.exists()
|
ruff (#169)
* polish: streamline nav, extract inline styles, improve tablet UX
- Restructure desktop nav from 8+ flat links + overflow dropdown into
5 grouped dropdowns (Core, Agents, Intel, System, More) matching
the mobile menu structure to reduce decision fatigue
- Extract all inline styles from mission_control.html and base.html
notification elements into mission-control.css with semantic classes
- Replace JS-built innerHTML with secure DOM construction in
notification loader and chat history
- Add CONNECTING state to connection indicator (amber) instead of
showing OFFLINE before WebSocket connects
- Add tablet breakpoint (1024px) with larger touch targets for
Apple Pencil / stylus use and safe-area padding for iPad toolbar
- Add active-link highlighting in desktop dropdown menus
- Rename "Mission Control" page title to "System Overview" to
disambiguate from the chat home page
- Add "Home — Timmy Time" page title to index.html
https://claude.ai/code/session_015uPUoKyYa8M2UAcyk5Gt6h
* fix(security): move auth-gate credentials to environment variables
Hardcoded username, password, and HMAC secret in auth-gate.py replaced
with os.environ lookups. Startup now refuses to run if any variable is
unset. Added AUTH_GATE_SECRET/USER/PASS to .env.example.
https://claude.ai/code/session_015uPUoKyYa8M2UAcyk5Gt6h
* refactor(tooling): migrate from black+isort+bandit to ruff
Replace three separate linting/formatting tools with a single ruff
invocation. Updates tox.ini (lint, format, pre-push, pre-commit envs),
.pre-commit-config.yaml, and CI workflow. Fixes all ruff errors
including unused imports, missing raise-from, and undefined names.
Ruff config maps existing bandit skips to equivalent S-rules.
https://claude.ai/code/session_015uPUoKyYa8M2UAcyk5Gt6h
---------
Co-authored-by: Claude <noreply@anthropic.com>
2026-03-11 12:23:35 -04:00
|
|
|
with open(agent_toml) as f:
|
2026-03-05 21:54:24 -05:00
|
|
|
content = f.read()
|
|
|
|
|
assert 'name = "hello-timmy"' in content
|
|
|
|
|
|
|
|
|
|
# Check Obsidian notes
|
|
|
|
|
hello_note = TEST_VAULT_DIR / "Hello World.md"
|
|
|
|
|
soul_note = TEST_VAULT_DIR / "SOUL.md"
|
|
|
|
|
assert hello_note.exists()
|
|
|
|
|
assert soul_note.exists()
|
2026-03-08 12:50:44 -04:00
|
|
|
|
ruff (#169)
* polish: streamline nav, extract inline styles, improve tablet UX
- Restructure desktop nav from 8+ flat links + overflow dropdown into
5 grouped dropdowns (Core, Agents, Intel, System, More) matching
the mobile menu structure to reduce decision fatigue
- Extract all inline styles from mission_control.html and base.html
notification elements into mission-control.css with semantic classes
- Replace JS-built innerHTML with secure DOM construction in
notification loader and chat history
- Add CONNECTING state to connection indicator (amber) instead of
showing OFFLINE before WebSocket connects
- Add tablet breakpoint (1024px) with larger touch targets for
Apple Pencil / stylus use and safe-area padding for iPad toolbar
- Add active-link highlighting in desktop dropdown menus
- Rename "Mission Control" page title to "System Overview" to
disambiguate from the chat home page
- Add "Home — Timmy Time" page title to index.html
https://claude.ai/code/session_015uPUoKyYa8M2UAcyk5Gt6h
* fix(security): move auth-gate credentials to environment variables
Hardcoded username, password, and HMAC secret in auth-gate.py replaced
with os.environ lookups. Startup now refuses to run if any variable is
unset. Added AUTH_GATE_SECRET/USER/PASS to .env.example.
https://claude.ai/code/session_015uPUoKyYa8M2UAcyk5Gt6h
* refactor(tooling): migrate from black+isort+bandit to ruff
Replace three separate linting/formatting tools with a single ruff
invocation. Updates tox.ini (lint, format, pre-push, pre-commit envs),
.pre-commit-config.yaml, and CI workflow. Fixes all ruff errors
including unused imports, missing raise-from, and undefined names.
Ruff config maps existing bandit skips to equivalent S-rules.
https://claude.ai/code/session_015uPUoKyYa8M2UAcyk5Gt6h
---------
Co-authored-by: Claude <noreply@anthropic.com>
2026-03-11 12:23:35 -04:00
|
|
|
with open(soul_note) as f:
|
2026-03-05 21:54:24 -05:00
|
|
|
content = f.read()
|
|
|
|
|
assert "I am Timmy" in content
|
|
|
|
|
|
2026-03-08 12:50:44 -04:00
|
|
|
|
2026-03-05 21:54:24 -05:00
|
|
|
def test_setup_install_dependencies():
|
|
|
|
|
"""Test that dependencies are correctly handled (OpenFang, Paperclip deps)."""
|
|
|
|
|
# Check if Paperclip node_modules exists (implies pnpm install ran)
|
|
|
|
|
# Note: In a real TDD we might mock pnpm, but here we want to verify the actual setup
|
|
|
|
|
node_modules = TEST_PROJECT_DIR / "paperclip/node_modules"
|
|
|
|
|
assert node_modules.exists()
|
|
|
|
|
|
2026-03-08 12:50:44 -04:00
|
|
|
|
2026-03-05 21:54:24 -05:00
|
|
|
def test_setup_start_stop_logic():
|
|
|
|
|
"""Test the start/stop command logic (simulated)."""
|
|
|
|
|
# This is harder to test fully without actually running the services,
|
|
|
|
|
# but we can check if the script handles the commands without crashing.
|
2026-03-08 12:50:44 -04:00
|
|
|
|
2026-03-05 21:54:24 -05:00
|
|
|
# Mocking start (it might fail if ports are taken, so we check return code)
|
|
|
|
|
# For the sake of this test, we just check if the script recognizes the command
|
|
|
|
|
result = run_setup_command(["status"])
|
|
|
|
|
assert "Status" in result.stdout or result.returncode == 0
|