from __future__ import annotations import unittest from unittest.mock import AsyncMock from services.conversation_history import ConversationRecorder class ConversationRecorderTest(unittest.IsolatedAsyncioTestCase): async def test_fixed_reply_transcript_keeps_workflow_metadata(self): recorder = ConversationRecorder("conv_test") recorder._append = AsyncMock() await recorder.record_transport_message( { "type": "transcript", "role": "assistant", "content": "请稍等,我正在处理。", "timestamp": "2026-07-14T10:00:00+08:00", "source": "workflow-fixed-reply", "nodeId": "agent_service", } ) recorder._append.assert_awaited_once_with( "assistant", "请稍等,我正在处理。", "2026-07-14T10:00:00+08:00", { "source": "workflow-fixed-reply", "node_id": "agent_service", }, ) if __name__ == "__main__": unittest.main()