feat: add resolution output API endpoints
Adds GET /outputs, PATCH /outputs/{id}, and POST /outputs/{id}/push
endpoints under /ai-sessions/{session_id}/, plus integration tests.
Router registered before ai_sessions to avoid path conflict.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
62
backend/tests/test_session_resolutions_api.py
Normal file
62
backend/tests/test_session_resolutions_api.py
Normal file
@@ -0,0 +1,62 @@
|
||||
"""API tests for resolution output endpoints."""
|
||||
import pytest
|
||||
from unittest.mock import patch
|
||||
from httpx import AsyncClient
|
||||
|
||||
from app.models.ai_session import AISession
|
||||
from app.models.session_resolution_output import SessionResolutionOutput
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_outputs_empty(client: AsyncClient, test_user, auth_headers, test_db):
|
||||
session = AISession(
|
||||
user_id=test_user["user_data"]["id"],
|
||||
account_id=test_user["user_data"]["account_id"],
|
||||
session_type="guided",
|
||||
intake_type="free_text",
|
||||
intake_content={"text": "test"},
|
||||
status="active",
|
||||
confidence_tier="guided",
|
||||
conversation_messages=[],
|
||||
)
|
||||
test_db.add(session)
|
||||
await test_db.commit()
|
||||
|
||||
resp = await client.get(f"/api/v1/ai-sessions/{session.id}/outputs", headers=auth_headers)
|
||||
assert resp.status_code == 200
|
||||
assert resp.json()["outputs"] == []
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_edit_output_api(client: AsyncClient, test_user, auth_headers, test_db):
|
||||
session = AISession(
|
||||
user_id=test_user["user_data"]["id"],
|
||||
account_id=test_user["user_data"]["account_id"],
|
||||
session_type="guided",
|
||||
intake_type="free_text",
|
||||
intake_content={"text": "test"},
|
||||
status="resolved",
|
||||
confidence_tier="guided",
|
||||
conversation_messages=[],
|
||||
resolution_summary="Fixed",
|
||||
)
|
||||
test_db.add(session)
|
||||
await test_db.flush()
|
||||
|
||||
output = SessionResolutionOutput(
|
||||
session_id=session.id,
|
||||
output_type="psa_ticket_notes",
|
||||
generated_content="Original",
|
||||
status="draft",
|
||||
generated_by_model="claude-sonnet-4-6",
|
||||
)
|
||||
test_db.add(output)
|
||||
await test_db.commit()
|
||||
|
||||
resp = await client.patch(
|
||||
f"/api/v1/ai-sessions/{session.id}/outputs/{output.id}",
|
||||
headers=auth_headers,
|
||||
json={"edited_content": "My edited version"},
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
assert resp.json()["edited_content"] == "My edited version"
|
||||
Reference in New Issue
Block a user