feat(api): Expand API hooks with drag and right_click actions
This commit is contained in:
@@ -81,4 +81,29 @@ def test_get_node_status() -> None:
|
||||
}
|
||||
status = client.get_node_status("T1")
|
||||
assert status["status"] == "todo"
|
||||
mock_make.assert_any_call('GET', '/api/mma/node/T1')
|
||||
mock_make.assert_any_call('GET', '/api/mma/node/T1')
|
||||
|
||||
def test_drag_success() -> None:
|
||||
"""Test that drag correctly sends a POST request to the /api/gui endpoint."""
|
||||
client = ApiHookClient()
|
||||
with patch.object(client, '_make_request') as mock_make:
|
||||
mock_make.return_value = {"status": "queued"}
|
||||
res = client.drag("src_id", "dst_id")
|
||||
assert res["status"] == "queued"
|
||||
mock_make.assert_any_call('POST', '/api/gui', data={
|
||||
"action": "drag",
|
||||
"src_item": "src_id",
|
||||
"dst_item": "dst_id"
|
||||
})
|
||||
|
||||
def test_right_click_success() -> None:
|
||||
"""Test that right_click correctly sends a POST request to the /api/gui endpoint."""
|
||||
client = ApiHookClient()
|
||||
with patch.object(client, '_make_request') as mock_make:
|
||||
mock_make.return_value = {"status": "queued"}
|
||||
res = client.right_click("item_id")
|
||||
assert res["status"] == "queued"
|
||||
mock_make.assert_any_call('POST', '/api/gui', data={
|
||||
"action": "right_click",
|
||||
"item": "item_id"
|
||||
})
|
||||
@@ -1,6 +1,6 @@
|
||||
from typing import Generator
|
||||
import pytest
|
||||
from unittest.mock import patch
|
||||
from unittest.mock import patch, Mock
|
||||
from src import ai_client
|
||||
from src.gui_2 import App
|
||||
|
||||
@@ -46,3 +46,23 @@ def test_gcli_path_updates_adapter(app_instance: App) -> None:
|
||||
app_instance.controller._process_pending_gui_tasks()
|
||||
assert ai_client._gemini_cli_adapter is not None
|
||||
assert ai_client._gemini_cli_adapter.binary_path == '/new/path/to/gemini'
|
||||
|
||||
def test_process_pending_gui_tasks_drag(app_instance: App) -> None:
|
||||
"""Test that the drag action is correctly processed and dispatches to the registered callback."""
|
||||
mock_callback = Mock()
|
||||
app_instance.controller._drag_actions["src_id"] = mock_callback
|
||||
app_instance.controller._pending_gui_tasks = [
|
||||
{"action": "drag", "src_item": "src_id", "dst_item": "dst_id"}
|
||||
]
|
||||
app_instance.controller._process_pending_gui_tasks()
|
||||
mock_callback.assert_called_once_with(dst_item="dst_id")
|
||||
|
||||
def test_process_pending_gui_tasks_right_click(app_instance: App) -> None:
|
||||
"""Test that the right_click action is correctly processed and dispatches to the registered callback."""
|
||||
mock_callback = Mock()
|
||||
app_instance.controller._right_clickable_actions["item_id"] = mock_callback
|
||||
app_instance.controller._pending_gui_tasks = [
|
||||
{"action": "right_click", "item": "item_id"}
|
||||
]
|
||||
app_instance.controller._process_pending_gui_tasks()
|
||||
mock_callback.assert_called_once()
|
||||
|
||||
Reference in New Issue
Block a user