Add analysis feature
This commit is contained in:
@@ -9,6 +9,45 @@ from services.conversation_history import ConversationRecorder
|
||||
|
||||
|
||||
class ConversationRecorderTest(unittest.IsolatedAsyncioTestCase):
|
||||
async def test_completed_conversation_queues_enabled_analysis(self):
|
||||
conversation = SimpleNamespace(
|
||||
status="active",
|
||||
ended_at=None,
|
||||
message_count=0,
|
||||
analysis_status="none",
|
||||
analysis_data={},
|
||||
analysis_error="",
|
||||
)
|
||||
|
||||
class FakeSession:
|
||||
async def __aenter__(self):
|
||||
return self
|
||||
|
||||
async def __aexit__(self, *_args):
|
||||
return None
|
||||
|
||||
async def get(self, _model, _session_id):
|
||||
return conversation
|
||||
|
||||
async def commit(self):
|
||||
return None
|
||||
|
||||
plan = {
|
||||
"enabled": True,
|
||||
"model_resource_id": "model_001",
|
||||
"fields": [{"name": "customer_name", "type": "string"}],
|
||||
}
|
||||
recorder = ConversationRecorder("conv_test", plan)
|
||||
recorder._sequence = 1
|
||||
with patch(
|
||||
"services.conversation_history.SessionLocal",
|
||||
return_value=FakeSession(),
|
||||
):
|
||||
await recorder._finish(status="completed")
|
||||
|
||||
self.assertEqual(conversation.analysis_status, "pending")
|
||||
self.assertEqual(conversation.analysis_data, {"plan": plan})
|
||||
|
||||
async def test_finish_waits_for_database_cleanup_when_cancelled(self):
|
||||
recorder = ConversationRecorder("conv_test")
|
||||
started = asyncio.Event()
|
||||
|
||||
Reference in New Issue
Block a user