fix(serialization): Fix Path serialization in events and thread-local fallback in ai_client

This commit is contained in:
2026-05-09 12:35:58 -04:00
parent c6e77f2b99
commit e313802a15
2 changed files with 73 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
import pytest
import time
import sys
import os
# Ensure project root is in path
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
from src.api_hook_client import ApiHookClient
def wait_for_value(client, field, expected, timeout=5):
"""Polls the GUI state until a field matches the expected value."""
start = time.time()
while time.time() - start < timeout:
val = client.get_value(field)
if val == expected:
return True
time.sleep(0.5)
return False
@pytest.mark.smoke
def test_status_hook(live_gui) -> None:
"""Smoke test for setting and getting ai_status and mma_status via ApiHookClient."""
client = ApiHookClient()
assert client.wait_for_server(timeout=10)
# 1. Set ai_status to 'hook_test'
client.set_value('ai_status', 'hook_test')
# 2. Verify via get_value('ai_status') == 'hook_test' (with retry)
assert wait_for_value(client, 'ai_status', 'hook_test'), f"Failed to set ai_status to hook_test. Current value: {client.get_value('ai_status')}"
# 3. Set mma_status to 'hook_mma_test'
client.set_value('mma_status', 'hook_mma_test')
# 4. Verify via get_value('mma_status') == 'hook_mma_test' (with retry)
assert wait_for_value(client, 'mma_status', 'hook_mma_test'), f"Failed to set mma_status to hook_mma_test. Current value: {client.get_value('mma_status')}"