fix(conductor): Apply review suggestions for track 'Add full api/hooks so that gemini cli can test, interact, and manipulate the state of the gui & program backend for automated testing.'

This commit is contained in:
2026-02-23 12:38:29 -05:00
parent 0070f61a40
commit dc64493f42
4 changed files with 44 additions and 14 deletions

View File

@@ -58,26 +58,41 @@ def test_ipc_server_starts_and_responds():
assert "session" in data
# Test project POST
req = urllib.request.Request("http://127.0.0.1:8999/api/project", method="POST", data=json.dumps({"project": {"foo": "bar"}}).encode("utf-8"), headers={'Content-Type': 'application/json'})
project_data = {"project": {"foo": "bar"}}
req = urllib.request.Request(
"http://127.0.0.1:8999/api/project",
method="POST",
data=json.dumps(project_data).encode("utf-8"),
headers={'Content-Type': 'application/json'})
with urllib.request.urlopen(req) as response:
assert response.status == 200
assert app_mock.project == {"foo": "bar"}
# Test session POST
req = urllib.request.Request("http://127.0.0.1:8999/api/session", method="POST", data=json.dumps({"session": {"entries": [{"role": "User", "content": "hi"}]}}).encode("utf-8"), headers={'Content-Type': 'application/json'})
session_data = {"session": {"entries": [{"role": "User", "content": "hi"}]}}
req = urllib.request.Request(
"http://127.0.0.1:8999/api/session",
method="POST",
data=json.dumps(session_data).encode("utf-8"),
headers={'Content-Type': 'application/json'})
with urllib.request.urlopen(req) as response:
assert response.status == 200
assert app_mock.disc_entries == [{"role": "User", "content": "hi"}]
# Test GUI queue hook
req = urllib.request.Request("http://127.0.0.1:8999/api/gui", method="POST", data=json.dumps({"action": "set_value", "item": "test_item", "value": "test_value"}).encode("utf-8"), headers={'Content-Type': 'application/json'})
gui_data = {"action": "set_value", "item": "test_item", "value": "test_value"}
req = urllib.request.Request(
"http://127.0.0.1:8999/api/gui",
method="POST",
data=json.dumps(gui_data).encode("utf-8"),
headers={'Content-Type': 'application/json'})
with urllib.request.urlopen(req) as response:
assert response.status == 200
# Instead of checking DPG (since we aren't running the real main loop in tests),
# check if it got queued in app_mock
assert hasattr(app_mock, '_pending_gui_tasks')
assert len(app_mock._pending_gui_tasks) == 1
assert app_mock._pending_gui_tasks[0] == {"action": "set_value", "item": "test_item", "value": "test_value"}
assert app_mock._pending_gui_tasks[0] == gui_data
finally:
server.stop()