checkpoint: mma_orchestrator track
This commit is contained in:
53
tests/test_mma_ticket_actions.py
Normal file
53
tests/test_mma_ticket_actions.py
Normal file
@@ -0,0 +1,53 @@
|
||||
import pytest
|
||||
from unittest.mock import patch, MagicMock
|
||||
import asyncio
|
||||
from gui_2 import App
|
||||
|
||||
@pytest.fixture
|
||||
def app_instance():
|
||||
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
|
||||
Reference in New Issue
Block a user