test(sim): Setup framework for robust live sim verification

This commit is contained in:
2026-02-27 23:20:42 -05:00
parent 173ffc31de
commit 2a30e62621
3 changed files with 75 additions and 0 deletions

View File

@@ -162,6 +162,26 @@ class ApiHookClient:
pass pass
return None return None
def get_text_value(self, item_tag):
"""Wraps get_value and returns its string representation, or None."""
val = self.get_value(item_tag)
return str(val) if val is not None else None
def get_node_status(self, node_tag):
"""Wraps get_value for a DAG node or queries the diagnostic endpoint for its status."""
val = self.get_value(node_tag)
if val is not None:
return val
try:
diag = self._make_request('GET', '/api/gui/diagnostics')
if 'nodes' in diag and node_tag in diag['nodes']:
return diag['nodes'][node_tag]
if node_tag in diag:
return diag[node_tag]
except Exception:
pass
return None
def click(self, item, *args, **kwargs): def click(self, item, *args, **kwargs):
"""Simulates a click on a GUI button or item.""" """Simulates a click on a GUI button or item."""
user_data = kwargs.pop('user_data', None) user_data = kwargs.pop('user_data', None)

View File

@@ -63,3 +63,38 @@ def test_unsupported_method_error():
client = ApiHookClient() client = ApiHookClient()
with pytest.raises(ValueError, match="Unsupported HTTP method"): with pytest.raises(ValueError, match="Unsupported HTTP method"):
client._make_request('PUT', '/some_endpoint', data={'key': 'value'}) client._make_request('PUT', '/some_endpoint', data={'key': 'value'})
def test_get_text_value():
"""
Test retrieval of string representation using get_text_value.
"""
client = ApiHookClient()
with patch.object(client, 'get_value', return_value=123):
assert client.get_text_value("dummy_tag") == "123"
with patch.object(client, 'get_value', return_value=None):
assert client.get_text_value("dummy_tag") is None
def test_get_node_status():
"""
Test retrieval of DAG node status using get_node_status.
"""
client = ApiHookClient()
# When get_value returns a status directly
with patch.object(client, 'get_value', return_value="running"):
assert client.get_node_status("my_node") == "running"
# When get_value returns None and diagnostics provides a nodes dict
with patch.object(client, 'get_value', return_value=None):
with patch.object(client, '_make_request', return_value={'nodes': {'my_node': 'completed'}}):
assert client.get_node_status("my_node") == "completed"
# When get_value returns None and diagnostics provides a direct key
with patch.object(client, 'get_value', return_value=None):
with patch.object(client, '_make_request', return_value={'my_node': 'failed'}):
assert client.get_node_status("my_node") == "failed"
# When neither works
with patch.object(client, 'get_value', return_value=None):
with patch.object(client, '_make_request', return_value={}):
assert client.get_node_status("my_node") is None

View File

@@ -0,0 +1,20 @@
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 api_hook_client import ApiHookClient
@pytest.mark.integration
def test_mma_epic_simulation(live_gui):
"""
Integration test for MMA epic simulation.
Red Phase: asserts False.
"""
client = ApiHookClient()
assert client.wait_for_server(timeout=10)
assert False, "Red Phase: Not yet implemented"