19 lines
774 B
Python
19 lines
774 B
Python
import sys
|
|
import os
|
|
from unittest.mock import patch
|
|
from gui_2 import App
|
|
|
|
# Ensure project root is in path
|
|
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
|
|
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "src")))
|
|
|
|
def test_gui_updates_on_event(app_instance: App) -> None:
|
|
app_instance.last_md = "mock_md"
|
|
with patch.object(app_instance, '_refresh_api_metrics') as mock_refresh:
|
|
# Simulate event (bypassing events.emit since _init_ai_and_hooks is mocked)
|
|
app_instance._on_api_event(payload={"text": "test"})
|
|
# Process tasks manually
|
|
app_instance._process_pending_gui_tasks()
|
|
# Verify that _refresh_api_metrics was called
|
|
mock_refresh.assert_called_once_with({"text": "test"}, md_content="mock_md")
|