feat(api): Add project and session state manipulation hooks
This commit is contained in:
@@ -42,5 +42,32 @@ def test_ipc_server_starts_and_responds():
|
||||
assert response.status == 200
|
||||
data = json.loads(response.read().decode())
|
||||
assert data.get("status") == "ok"
|
||||
|
||||
# Test project GET
|
||||
req = urllib.request.Request("http://127.0.0.1:8999/api/project")
|
||||
with urllib.request.urlopen(req) as response:
|
||||
assert response.status == 200
|
||||
data = json.loads(response.read().decode())
|
||||
assert "project" in data
|
||||
|
||||
# Test session GET
|
||||
req = urllib.request.Request("http://127.0.0.1:8999/api/session")
|
||||
with urllib.request.urlopen(req) as response:
|
||||
assert response.status == 200
|
||||
data = json.loads(response.read().decode())
|
||||
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'})
|
||||
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'})
|
||||
with urllib.request.urlopen(req) as response:
|
||||
assert response.status == 200
|
||||
assert app_mock.disc_entries == [{"role": "User", "content": "hi"}]
|
||||
|
||||
finally:
|
||||
server.stop()
|
||||
|
||||
Reference in New Issue
Block a user