ForcePilot/backend/test/integration/api/test_chat_agent_sync.py

43 lines
1.4 KiB
Python
Raw Normal View History

"""
2026-05-29 22:19:58 +08:00
Integration tests for current agent run endpoints.
"""
from __future__ import annotations
2026-05-29 22:19:58 +08:00
import uuid
import pytest
pytestmark = [pytest.mark.asyncio, pytest.mark.integration]
2026-05-29 22:19:58 +08:00
async def test_agent_run_endpoints_require_authentication(test_client):
run_id = str(uuid.uuid4())
2026-05-29 22:19:58 +08:00
create_response = await test_client.post(
"/api/agent/runs",
json={"query": "hello", "agent_id": "default-chatbot", "thread_id": str(uuid.uuid4())},
)
2026-05-29 22:19:58 +08:00
assert create_response.status_code == 401
assert (await test_client.get(f"/api/agent/runs/{run_id}")).status_code == 401
assert (await test_client.post(f"/api/agent/runs/{run_id}/cancel")).status_code == 401
2026-05-29 22:19:58 +08:00
async def test_agent_run_create_rejects_empty_input(test_client, admin_headers):
response = await test_client.post(
2026-05-29 22:19:58 +08:00
"/api/agent/runs",
json={"query": "", "agent_id": "default-chatbot", "thread_id": str(uuid.uuid4())},
headers=admin_headers,
)
2026-05-29 22:19:58 +08:00
assert response.status_code == 422
2026-05-29 22:19:58 +08:00
async def test_agent_run_missing_resource_returns_not_found(test_client, admin_headers):
run_id = str(uuid.uuid4())
2026-05-29 22:19:58 +08:00
get_response = await test_client.get(f"/api/agent/runs/{run_id}", headers=admin_headers)
assert get_response.status_code == 404
2026-05-29 22:19:58 +08:00
cancel_response = await test_client.post(f"/api/agent/runs/{run_id}/cancel", headers=admin_headers)
assert cancel_response.status_code == 404