33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
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()
|