Applied 236 return type annotations to functions with no return values across 100+ files (core modules, tests, scripts, simulations). Added Phase 4 to python_style_refactor track for remaining 597 items (untyped params, vars, and functions with return values). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
48 lines
1.6 KiB
Python
48 lines
1.6 KiB
Python
import pytest
|
|
from unittest.mock import patch, MagicMock
|
|
import asyncio
|
|
from gui_2 import App
|
|
|
|
@pytest.fixture
|
|
def app_instance() -> None:
|
|
with (
|
|
patch('gui_2.load_config', return_value={'ai': {}, 'projects': {}}),
|
|
patch('gui_2.save_config'),
|
|
patch('gui_2.project_manager'),
|
|
patch('gui_2.session_logger'),
|
|
patch('gui_2.immapp.run'),
|
|
patch.object(App, '_load_active_project'),
|
|
patch.object(App, '_fetch_models'),
|
|
patch.object(App, '_load_fonts'),
|
|
patch.object(App, '_post_init')
|
|
):
|
|
app = App()
|
|
app.active_tickets = []
|
|
app._loop = MagicMock()
|
|
yield app
|
|
|
|
def test_cb_ticket_retry(app_instance):
|
|
ticket_id = "test_ticket_1"
|
|
app_instance.active_tickets = [{"id": ticket_id, "status": "failed"}]
|
|
with patch('asyncio.run_coroutine_threadsafe') as mock_run_safe:
|
|
app_instance._cb_ticket_retry(ticket_id)
|
|
# Verify status update
|
|
assert app_instance.active_tickets[0]['status'] == 'todo'
|
|
# Verify event pushed
|
|
mock_run_safe.assert_called_once()
|
|
# First arg is the coroutine (event_queue.put), second is self._loop
|
|
args, _ = mock_run_safe.call_args
|
|
assert args[1] == app_instance._loop
|
|
|
|
def test_cb_ticket_skip(app_instance):
|
|
ticket_id = "test_ticket_1"
|
|
app_instance.active_tickets = [{"id": ticket_id, "status": "todo"}]
|
|
with patch('asyncio.run_coroutine_threadsafe') as mock_run_safe:
|
|
app_instance._cb_ticket_skip(ticket_id)
|
|
# Verify status update
|
|
assert app_instance.active_tickets[0]['status'] == 'skipped'
|
|
# Verify event pushed
|
|
mock_run_safe.assert_called_once()
|
|
args, _ = mock_run_safe.call_args
|
|
assert args[1] == app_instance._loop
|