Files
manual_slop/tests/verify_mma_gui_robust.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

88 lines
2.8 KiB
Python

import subprocess
import time
import sys
import os
import unittest
# Calculate project root
PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
if PROJECT_ROOT not in sys.path:
sys.path.insert(0, PROJECT_ROOT)
from api_hook_client import ApiHookClient
class TestMMAGUIRobust(unittest.TestCase):
@classmethod
def setUpClass(cls):
# 1. Launch gui_2.py with --enable-test-hooks
cls.gui_command = [sys.executable, "gui_2.py", "--enable-test-hooks"]
print(f"Launching GUI: {' '.join(cls.gui_command)}")
cls.gui_process = subprocess.Popen(
cls.gui_command,
cwd=PROJECT_ROOT,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True
)
cls.client = ApiHookClient()
print("Waiting for GUI to start...")
if not cls.client.wait_for_server(timeout=10):
cls.gui_process.terminate()
raise RuntimeError("GUI failed to start or hook server not responsive.")
print("GUI started.")
@classmethod
def tearDownClass(cls) -> None:
if cls.gui_process:
cls.gui_process.terminate()
cls.gui_process.wait(timeout=5)
def test_mma_state_ingestion(self) -> None:
"""Verify that mma_state_update event correctly updates GUI state."""
track_data = {
"id": "robust_test_track",
"title": "Robust Verification Track",
"description": "Verifying internal state ingestion"
}
tickets_data = [
{"id": "T1", "target_file": "file1.py", "status": "todo"},
{"id": "T2", "target_file": "file2.py", "status": "running"},
{"id": "T3", "target_file": "file3.py", "status": "complete"},
]
payload = {
"status": "active",
"active_tier": "Tier 2",
"track": track_data,
"tickets": tickets_data
}
print("Pushing mma_state_update...")
self.client.push_event("mma_state_update", payload)
# Give GUI a moment to process the async task
time.sleep(1.0)
print("Querying mma_status...")
status = self.client.get_mma_status()
self.assertEqual(status["mma_status"], "active")
self.assertEqual(status["active_tier"], "Tier 2")
self.assertEqual(status["active_track"]["id"], "robust_test_track")
self.assertEqual(len(status["active_tickets"]), 3)
self.assertEqual(status["active_tickets"][2]["status"], "complete")
print("MMA state ingestion verified successfully.")
def test_mma_step_approval_trigger(self) -> None:
"""Verify that mma_step_approval event sets the pending approval flag."""
payload = {
"ticket_id": "T2",
"payload": "echo 'Robust Test'"
}
print("Pushing mma_step_approval...")
self.client.push_event("mma_step_approval", payload)
time.sleep(1.0)
print("Querying mma_status for pending approval...")
status = self.client.get_mma_status()
self.assertTrue(status["pending_approval"], "GUI did not register pending MMA approval")
print("MMA step approval trigger verified successfully.")
if __name__ == "__main__":
unittest.main()