feat: protocol generation — LLM integration, prompt templates, Celery task
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import pytest
|
||||
from unittest.mock import patch, MagicMock
|
||||
|
||||
from app.services.protocol_generator import generate_protocol_text
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_generate_protocol_text_returns_structured_result():
|
||||
mock_template = MagicMock()
|
||||
mock_template.system_prompt = "You are an analyst."
|
||||
mock_template.user_prompt = "Create protocol from: {transcription}"
|
||||
|
||||
mock_response = MagicMock()
|
||||
mock_response.choices = [MagicMock()]
|
||||
mock_response.choices[0].message.content = '{"topic": "Test meeting", "decisions": ["Decision 1"]}'
|
||||
mock_response.model = "test-model"
|
||||
|
||||
with patch("app.services.protocol_generator.completion", return_value=mock_response):
|
||||
result = generate_protocol_text("Hello this is a meeting", mock_template)
|
||||
|
||||
assert result["content"]["topic"] == "Test meeting"
|
||||
assert result["raw_text"] == '{"topic": "Test meeting", "decisions": ["Decision 1"]}'
|
||||
assert result["model"] == "test-model"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_generate_protocol_text_handles_non_json_response():
|
||||
mock_template = MagicMock()
|
||||
mock_template.system_prompt = "You are an analyst."
|
||||
mock_template.user_prompt = "Create protocol from: {transcription}"
|
||||
|
||||
mock_response = MagicMock()
|
||||
mock_response.choices = [MagicMock()]
|
||||
mock_response.choices[0].message.content = "Not valid JSON response"
|
||||
mock_response.model = "test-model"
|
||||
|
||||
with patch("app.services.protocol_generator.completion", return_value=mock_response):
|
||||
result = generate_protocol_text("Hello", mock_template)
|
||||
|
||||
assert "raw" in result["content"]
|
||||
assert result["content"]["raw"] == "Not valid JSON response"
|
||||
Reference in New Issue
Block a user