WIP: PAIN4
This commit is contained in:
@@ -1,27 +1,17 @@
|
||||
from unittest.mock import patch
|
||||
from gui_2 import App
|
||||
from src.gui_2 import App
|
||||
|
||||
def test_cb_ticket_retry(app_instance: App) -> None:
|
||||
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
|
||||
# Synchronous implementation does not use asyncio.run_coroutine_threadsafe
|
||||
app_instance.controller._cb_ticket_retry(ticket_id)
|
||||
# Verify status update
|
||||
assert app_instance.active_tickets[0]['status'] == 'todo'
|
||||
|
||||
def test_cb_ticket_skip(app_instance: App) -> None:
|
||||
ticket_id = "test_ticket_1"
|
||||
ticket_id = "test_ticket_2"
|
||||
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
|
||||
app_instance.controller._cb_ticket_skip(ticket_id)
|
||||
# Verify status update
|
||||
assert app_instance.active_tickets[0]['status'] == 'skipped'
|
||||
|
||||
Reference in New Issue
Block a user