forked from Rockachopa/Timmy-time-dashboard
feat: code quality audit + autoresearch integration + infra hardening (#150)
This commit is contained in:
committed by
GitHub
parent
fd0ede0d51
commit
ae3bb1cc21
@@ -1,9 +1,10 @@
|
||||
import os
|
||||
import subprocess
|
||||
import shutil
|
||||
import pytest
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
# Constants for testing
|
||||
TEST_PROJECT_DIR = Path("/home/ubuntu/test-sovereign-stack")
|
||||
TEST_VAULT_DIR = TEST_PROJECT_DIR / "TimmyVault"
|
||||
@@ -14,6 +15,7 @@ pytestmark = pytest.mark.skipif(
|
||||
reason=f"Setup script not found at {SETUP_SCRIPT_PATH}",
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(scope="module", autouse=True)
|
||||
def cleanup_test_env():
|
||||
"""Ensure a clean environment before and after tests."""
|
||||
@@ -23,26 +25,25 @@ def cleanup_test_env():
|
||||
# We keep the test env for manual inspection if needed, or cleanup
|
||||
# shutil.rmtree(TEST_PROJECT_DIR)
|
||||
|
||||
|
||||
def run_setup_command(args):
|
||||
"""Helper to run the setup script with arguments."""
|
||||
result = subprocess.run(
|
||||
[str(SETUP_SCRIPT_PATH)] + args,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
cwd="/home/ubuntu"
|
||||
[str(SETUP_SCRIPT_PATH)] + args, capture_output=True, text=True, cwd="/home/ubuntu"
|
||||
)
|
||||
return result
|
||||
|
||||
|
||||
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"
|
||||
|
||||
|
||||
result = run_setup_command(["install"])
|
||||
|
||||
|
||||
# Check if command succeeded
|
||||
assert result.returncode == 0, f"Setup install failed: {result.stderr}"
|
||||
|
||||
|
||||
# Check directory structure
|
||||
assert TEST_PROJECT_DIR.exists()
|
||||
assert (TEST_PROJECT_DIR / "paperclip").exists()
|
||||
@@ -50,6 +51,7 @@ def test_setup_install_creates_directories():
|
||||
assert TEST_VAULT_DIR.exists()
|
||||
assert (TEST_PROJECT_DIR / "logs").exists()
|
||||
|
||||
|
||||
def test_setup_install_creates_files():
|
||||
"""Test that './setup_timmy.sh install' creates the expected configuration and notes."""
|
||||
# Check Agent config
|
||||
@@ -64,11 +66,12 @@ def test_setup_install_creates_files():
|
||||
soul_note = TEST_VAULT_DIR / "SOUL.md"
|
||||
assert hello_note.exists()
|
||||
assert soul_note.exists()
|
||||
|
||||
|
||||
with open(soul_note, "r") as f:
|
||||
content = f.read()
|
||||
assert "I am Timmy" in content
|
||||
|
||||
|
||||
def test_setup_install_dependencies():
|
||||
"""Test that dependencies are correctly handled (OpenFang, Paperclip deps)."""
|
||||
# Check if Paperclip node_modules exists (implies pnpm install ran)
|
||||
@@ -76,11 +79,12 @@ def test_setup_install_dependencies():
|
||||
node_modules = TEST_PROJECT_DIR / "paperclip/node_modules"
|
||||
assert node_modules.exists()
|
||||
|
||||
|
||||
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.
|
||||
|
||||
|
||||
# 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"])
|
||||
|
||||
Reference in New Issue
Block a user