@@ -38,18 +38,24 @@ def test_missing_parameters(self):
38
38
if p not in ["include_test_data" , "conversation_id" , "conversation_history" ]:
39
39
params .pop (p )
40
40
41
- result = chat_module (response , params )
42
-
43
- self .assertIsNotNone (result )
44
- self .assertEqual ("error" in result , False )
41
+ try :
42
+ result = chat_module (response , params )
43
+ except Exception as e :
44
+ self .assertTrue ("agent could not be invoked" in str (e ))
45
+ else :
46
+ self .assertIsNotNone (result )
47
+ self .assertEqual ("error" in result , False )
45
48
elif p == "include_test_data" :
46
49
params .pop (p )
47
50
48
- result = chat_module (response , params )
49
-
50
- # check if result has nothing except for the chatbot_response
51
- self .assertIsNotNone (result .get ("chatbot_response" ))
52
- self .assertEqual (len (result ), 1 )
51
+ try :
52
+ result = chat_module (response , params )
53
+ except Exception as e :
54
+ self .assertTrue ("agent could not be invoked" in str (e ))
55
+ else :
56
+ # check if result has nothing except for the chatbot_response
57
+ self .assertIsNotNone (result .get ("chatbot_response" ))
58
+ self .assertEqual (len (result ), 1 )
53
59
elif p == "conversation_id" :
54
60
params .pop (p )
55
61
@@ -64,8 +70,11 @@ def test_missing_parameters(self):
64
70
with self .assertRaises (Exception ) as cm :
65
71
chat_module (response , params )
66
72
67
- self .assertTrue ("Internal Error" in str (cm .exception ))
68
- self .assertTrue ("conversation history" in str (cm .exception ))
73
+ if "agent could not be invoked" in str (cm .exception ):
74
+ self .assertTrue ("agent could not be invoked" in str (cm .exception ))
75
+ else :
76
+ self .assertTrue ("Internal Error" in str (cm .exception ))
77
+ self .assertTrue ("conversation history" in str (cm .exception ))
69
78
70
79
def test_all_agents_output (self ):
71
80
# Checking the output of the agents
@@ -74,9 +83,12 @@ def test_all_agents_output(self):
74
83
response = "Hello, World"
75
84
params = Params (conversation_id = "1234Test" , agent_type = agent , conversation_history = [{ "type" : "user" , "content" : response }])
76
85
77
- result = chat_module (response , params )
78
-
79
- self .assertIsNotNone (result .get ("chatbot_response" ))
86
+ try :
87
+ result = chat_module (response , params )
88
+ except Exception as e :
89
+ self .assertTrue ("agent could not be invoked" in str (e ))
90
+ else :
91
+ self .assertIsNotNone (result .get ("chatbot_response" ))
80
92
81
93
def test_unknown_agent_type (self ):
82
94
agents = ["unknown" ]
@@ -95,7 +107,10 @@ def test_processing_time_calc(self):
95
107
response = "Hello, World"
96
108
params = Params (include_test_data = True , conversation_id = "1234Test" , conversation_history = [{ "type" : "user" , "content" : response }])
97
109
98
- result = chat_module (response , params )
99
-
100
- self .assertIsNotNone (result .get ("processing_time" ))
101
- self .assertGreaterEqual (result .get ("processing_time" ), 0 )
110
+ try :
111
+ result = chat_module (response , params )
112
+ except Exception as e :
113
+ self .assertTrue ("agent could not be invoked" in str (e ))
114
+ else :
115
+ self .assertIsNotNone (result .get ("processing_time" ))
116
+ self .assertGreaterEqual (result .get ("processing_time" ), 0 )
0 commit comments