test: baseline test suite — 86 tests covering auth, CRUD, settings, chat, terraform, reports, terminal

This commit is contained in:
nogueiraguh
2026-04-03 17:31:39 -03:00
parent 856e3b6674
commit 2e74d316ae
13 changed files with 1126 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
"""Tests for chat session management endpoints."""
import pytest
@pytest.mark.anyio
async def test_list_sessions_empty(client, user_headers):
r = await client.get("/api/chat/sessions", headers=user_headers)
assert r.status_code == 200
body = r.json()
assert isinstance(body, list)
@pytest.mark.anyio
async def test_create_session_via_message(client, user_headers):
"""POST /api/chat with a fake genai config.
The endpoint should respond without a 500 — it may return 200 with a
message_id (background processing will fail) or 400/404 if the config
is not found.
"""
r = await client.post(
"/api/chat",
json={"message": "hello", "genai_config_id": "fake"},
headers=user_headers,
)
assert r.status_code != 500, f"Unexpected server error: {r.text}"
@pytest.mark.anyio
async def test_list_sessions(client, user_headers):
r = await client.get("/api/chat/sessions", headers=user_headers)
assert r.status_code == 200
assert isinstance(r.json(), list)
@pytest.mark.anyio
async def test_rename_session(client, user_headers):
"""Rename a session if one exists, otherwise skip gracefully."""
sessions = (await client.get("/api/chat/sessions", headers=user_headers)).json()
if not sessions:
pytest.skip("No chat session available to rename")
sid = sessions[0]["id"]
r = await client.put(
f"/api/chat/sessions/{sid}/title",
json={"title": "renamed"},
headers=user_headers,
)
assert r.status_code == 200
@pytest.mark.anyio
async def test_delete_session(client, user_headers):
"""Delete a session if one exists, otherwise skip gracefully."""
sessions = (await client.get("/api/chat/sessions", headers=user_headers)).json()
if not sessions:
pytest.skip("No chat session available to delete")
sid = sessions[0]["id"]
r = await client.delete(f"/api/chat/{sid}", headers=user_headers)
assert r.status_code == 200