36 lines
1.3 KiB
Python
36 lines
1.3 KiB
Python
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')}"
|