async def test_should_not_log_continue_conversation(self): transcript_store = MemoryTranscriptStore() conversation_id = "" sut = TranscriptLoggerMiddleware(transcript_store) async def aux_logic(context: TurnContext): nonlocal conversation_id conversation_id = context.activity.conversation.id adapter = TestAdapter(aux_logic) adapter.use(sut) continue_conversation_activity = Activity( type=ActivityTypes.event, name=ActivityEventNames.continue_conversation) test_flow = TestFlow(None, adapter) step1 = await test_flow.send("foo") step2 = await step1.send("bar") await step2.send(continue_conversation_activity) paged_result = await transcript_store.get_transcript_activities( "test", conversation_id) self.assertEqual( len(paged_result.items), 2, "only the two message activities should be logged", )
async def test_get_single_activity(self): memory_transcript = MemoryTranscriptStore() conversation_id = "_log_activity" date = datetime.datetime.now() activity = self.create_activities(conversation_id, date, count=1)[-1] await memory_transcript.log_activity(activity) result = await memory_transcript.get_transcript_activities( "test", conversation_id) self.assertNotEqual(result.items, None) self.assertEqual(result.items[0].text, "0")
async def test_get_multiple_activity(self): memory_transcript = MemoryTranscriptStore() conversation_id = "_log_activity" date = datetime.datetime.now() activities = self.create_activities(conversation_id, date, count=10) for activity in activities: await memory_transcript.log_activity(activity) result = await memory_transcript.get_transcript_activities( "test", conversation_id) self.assertNotEqual(result.items, None) self.assertEqual(len(result.items), 20) # 2 events logged each iteration
async def test_get_activity_none(self): memory_transcript = MemoryTranscriptStore() conversation_id = "_log_activity" await memory_transcript.get_transcript_activities( "test", conversation_id)
async def test_log_activity(self): memory_transcript = MemoryTranscriptStore() conversation_id = "_log_activity" date = datetime.datetime.now() activity = self.create_activities(conversation_id, date, 1)[-1] await memory_transcript.log_activity(activity)
async def test_null_transcript_store(self): memory_transcript = MemoryTranscriptStore() with self.assertRaises(TypeError): await memory_transcript.log_activity(None)