feat(perf): Add get_ui_performance AI tool
This commit is contained in:
32
tests/test_mcp_perf_tool.py
Normal file
32
tests/test_mcp_perf_tool.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import unittest
|
||||
from unittest.mock import MagicMock
|
||||
import mcp_client
|
||||
|
||||
class TestMCPPerfTool(unittest.TestCase):
|
||||
def test_get_ui_performance_dispatch(self):
|
||||
# Mock the callback
|
||||
mock_metrics = {
|
||||
'last_frame_time_ms': 16.6,
|
||||
'fps': 60.0,
|
||||
'cpu_percent': 15.5,
|
||||
'input_lag_ms': 5.0
|
||||
}
|
||||
mcp_client.perf_monitor_callback = MagicMock(return_value=mock_metrics)
|
||||
|
||||
# Test dispatch
|
||||
result = mcp_client.dispatch("get_ui_performance", {})
|
||||
|
||||
self.assertIn("UI Performance Snapshot:", result)
|
||||
self.assertIn("last_frame_time_ms: 16.6", result)
|
||||
self.assertIn("fps: 60.0", result)
|
||||
self.assertIn("cpu_percent: 15.5", result)
|
||||
self.assertIn("input_lag_ms: 5.0", result)
|
||||
|
||||
mcp_client.perf_monitor_callback.assert_called_once()
|
||||
|
||||
def test_tool_spec_exists(self):
|
||||
spec_names = [spec["name"] for spec in mcp_client.MCP_TOOL_SPECS]
|
||||
self.assertIn("get_ui_performance", spec_names)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user