-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest_places_replication.py
37 lines (31 loc) · 1.88 KB
/
test_places_replication.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import unittest
from llm_engines import LLMApi, ChatgptLLM
from places_replication import NaiveConversationGeneration, NaiveConversationAgent
class TestNaiveConversationGeneration(unittest.TestCase):
def setUp(self):
self.llm = ChatgptLLM()
self.agent_list = [NaiveConversationAgent("Alice", llm=self.llm), NaiveConversationAgent("Bob", llm=self.llm)]
self.topics_to_cover = ["Paris", "London"]
self.conversation_generator = NaiveConversationGeneration(self.agent_list, self.llm, self.topics_to_cover)
def test_generate_conversation(self):
conversation = self.conversation_generator.generate_conversation(min_turns=10, start_conversation=True)
self.assertEqual(len(conversation), 10)
self.assertIn(conversation[0][1], [agent.name for agent in self.agent_list])
self.assertIn(conversation[0][2], [conversation_start for conversation_start in self.conversation_generator.conversation_starters])
def test_print_chat_history(self):
# Assuming conversation history is not empty
self.conversation_generator.generate_conversation(min_turns=5, start_conversation=True)
self.conversation_generator.print_chat_history()
# No assertion, just checking if it prints without errors
def test_save_chat_history(self):
# Assuming conversation history is not empty
self.conversation_generator.generate_conversation(min_turns=5, start_conversation=True)
self.conversation_generator.save_chat_history()
# No assertion, just checking if it saves without errors
def test_dump_chat(self):
# Assuming conversation history is not empty
self.conversation_generator.generate_conversation(min_turns=5, start_conversation=True)
self.conversation_generator.dump_chat()
# No assertion, just checking if it dumps without errors
if __name__ == '__main__':
unittest.main()