Files
manual_slop/tests/test_hooks.py
Ed_ 60396f03f8 refactor(types): auto -> None sweep across entire codebase
Applied 236 return type annotations to functions with no return values
across 100+ files (core modules, tests, scripts, simulations).
Added Phase 4 to python_style_refactor track for remaining 597 items
(untyped params, vars, and functions with return values).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 11:16:56 -05:00

47 lines
1.3 KiB
Python

import os
import sys
import pytest
import requests
import json
from unittest.mock import patch
# Ensure project root is in path
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
from api_hook_client import ApiHookClient
import gui_legacy
def test_hooks_enabled_via_cli() -> None:
with patch.object(sys, 'argv', ['gui_legacy.py', '--enable-test-hooks']):
app = gui_legacy.App()
assert app.test_hooks_enabled is True
def test_hooks_disabled_by_default() -> None:
with patch.object(sys, 'argv', ['gui_legacy.py']):
if 'SLOP_TEST_HOOKS' in os.environ:
del os.environ['SLOP_TEST_HOOKS']
app = gui_legacy.App()
assert getattr(app, 'test_hooks_enabled', False) is False
def test_live_hook_server_responses(live_gui):
"""
Verifies the live hook server (started via fixture) responds correctly to all major endpoints.
"""
client = ApiHookClient()
# Test /status
status = client.get_status()
assert status == {'status': 'ok'}
# Test /api/project
project = client.get_project()
assert 'project' in project
# Test /api/session
session = client.get_session()
assert 'session' in session
# Test /api/performance
perf = client.get_performance()
assert 'performance' in perf
# Test POST /api/gui
gui_data = {"action": "test_action", "value": 42}
resp = client.post_gui(gui_data)
assert resp == {'status': 'queued'}