@@ -27,15 +27,15 @@ class TestChatModuleFunction(unittest.TestCase):
2727
2828 def test_missing_parameters (self ):
2929 # Checking state for missing parameters on default agent
30- response , params = "Hello, World" , Params ()
31- expected_params = Params (include_test_data = True , conversation_history = [], \
30+ response = "Hello, World"
31+ expected_params = Params (include_test_data = True , conversation_history = [{ "type" : "user" , "content" : response } ], \
3232 summary = "" , conversational_style = "" , \
3333 question_response_details = {}, conversation_id = "1234Test" )
3434
3535 for p in expected_params :
3636 params = expected_params .copy ()
3737 # except for the special parameters
38- if p not in ["include_test_data" , "conversation_id" ]:
38+ if p not in ["include_test_data" , "conversation_id" , "conversation_history" ]:
3939 params .pop (p )
4040
4141 result = chat_module (response , params )
@@ -58,20 +58,42 @@ def test_missing_parameters(self):
5858
5959 self .assertTrue ("Internal Error" in str (cm .exception ))
6060 self .assertTrue ("conversation id" in str (cm .exception ))
61+ elif p == "conversation_history" :
62+ params .pop (p )
63+
64+ with self .assertRaises (Exception ) as cm :
65+ chat_module (response , params )
66+
67+ self .assertTrue ("Internal Error" in str (cm .exception ))
68+ self .assertTrue ("conversation history" in str (cm .exception ))
6169
6270 def test_all_agents_output (self ):
6371 # Checking the output of the agents
6472 agents = ["informational" , "socratic" ]
6573 for agent in agents :
66- response , params = "Hello, World" , Params (conversation_id = "1234Test" , agent_type = agent )
74+ response = "Hello, World"
75+ params = Params (conversation_id = "1234Test" , agent_type = agent , conversation_history = [{ "type" : "user" , "content" : response }])
6776
6877 result = chat_module (response , params )
6978
7079 self .assertIsNotNone (result .get ("chatbot_response" ))
71-
80+
81+ def test_unknown_agent_type (self ):
82+ agents = ["unknown" ]
83+ for agent in agents :
84+ response = "Hello, World"
85+ params = Params (conversation_id = "1234Test" , agent_type = agent , conversation_history = [{ "type" : "user" , "content" : response }])
86+
87+ with self .assertRaises (Exception ) as cm :
88+ chat_module (response , params )
89+
90+ self .assertTrue ("Input Parameter Error:" in str (cm .exception ))
91+ self .assertTrue ("Agent Type" in str (cm .exception ))
92+
7293 def test_processing_time_calc (self ):
7394 # Checking the processing time calculation
74- response , params = "Hello, World" , Params (include_test_data = True , conversation_id = "1234Test" )
95+ response = "Hello, World"
96+ params = Params (include_test_data = True , conversation_id = "1234Test" , conversation_history = [{ "type" : "user" , "content" : response }])
7597
7698 result = chat_module (response , params )
7799
0 commit comments