@@ -66,7 +66,8 @@ def test_retrieve_conversation_id_existing_id():
66
66
@pytest .mark .usefixtures ("_load_config" )
67
67
def test_retrieve_previous_input_no_previous_history ():
68
68
"""Check how function to retrieve previous input handle empty history."""
69
- llm_request = LLMRequest (query = "Tell me about Kubernetes" , conversation_id = None )
69
+ llm_request = LLMRequest (query = "Tell me about Kubernetes" , conversation_id = "" )
70
+ assert llm_request .conversation_id is not None
70
71
llm_input = ols .retrieve_previous_input (
71
72
constants .DEFAULT_USER_UID , llm_request .conversation_id
72
73
)
@@ -80,6 +81,7 @@ def test_retrieve_previous_input_empty_user_id():
80
81
llm_request = LLMRequest (
81
82
query = "Tell me about Kubernetes" , conversation_id = conversation_id
82
83
)
84
+ assert llm_request .conversation_id is not None
83
85
# cache must check if user ID is correct
84
86
with pytest .raises (HTTPException , match = "Invalid user ID" ):
85
87
ols .retrieve_previous_input ("" , llm_request .conversation_id )
@@ -94,6 +96,7 @@ def test_retrieve_previous_input_improper_user_id():
94
96
llm_request = LLMRequest (
95
97
query = "Tell me about Kubernetes" , conversation_id = conversation_id
96
98
)
99
+ assert llm_request .conversation_id is not None
97
100
# cache must check if user ID is correct
98
101
with pytest .raises (HTTPException , match = "Invalid user ID improper_user_id" ):
99
102
ols .retrieve_previous_input ("improper_user_id" , llm_request .conversation_id )
@@ -108,6 +111,7 @@ def test_retrieve_previous_input_for_previous_history():
108
111
llm_request = LLMRequest (
109
112
query = "Tell me about Kubernetes" , conversation_id = conversation_id
110
113
)
114
+ assert llm_request .conversation_id is not None
111
115
previous_input = ols .retrieve_previous_input (
112
116
constants .DEFAULT_USER_UID , llm_request .conversation_id
113
117
)
@@ -150,11 +154,11 @@ def test_retrieve_attachments_on_proper_input():
150
154
query = "Tell me about Kubernetes" ,
151
155
conversation_id = conversation_id ,
152
156
attachments = [
153
- {
154
- " attachment_type" : "log" ,
155
- " content_type" : "text/plain" ,
156
- " content" : "this is attachment" ,
157
- } ,
157
+ Attachment (
158
+ attachment_type = "log" ,
159
+ content_type = "text/plain" ,
160
+ content = "this is attachment" ,
161
+ ) ,
158
162
],
159
163
)
160
164
attachments = ols .retrieve_attachments (llm_request )
@@ -176,11 +180,11 @@ def test_retrieve_attachments_on_improper_attachment_type():
176
180
query = "Tell me about Kubernetes" ,
177
181
conversation_id = conversation_id ,
178
182
attachments = [
179
- {
180
- " attachment_type" : "not-correct-one" ,
181
- " content_type" : "text/plain" ,
182
- " content" : "this is attachment" ,
183
- } ,
183
+ Attachment (
184
+ attachment_type = "not-correct-one" ,
185
+ content_type = "text/plain" ,
186
+ content = "this is attachment" ,
187
+ ) ,
184
188
],
185
189
)
186
190
with pytest .raises (
@@ -197,11 +201,11 @@ def test_retrieve_attachments_on_improper_content_type():
197
201
query = "Tell me about Kubernetes" ,
198
202
conversation_id = conversation_id ,
199
203
attachments = [
200
- {
201
- " attachment_type" : "log" ,
202
- " content_type" : "not/known" ,
203
- " content" : "this is attachment" ,
204
- } ,
204
+ Attachment (
205
+ attachment_type = "log" ,
206
+ content_type = "not/known" ,
207
+ content = "this is attachment" ,
208
+ ) ,
205
209
],
206
210
)
207
211
with pytest .raises (
@@ -226,7 +230,7 @@ def test_store_conversation_history():
226
230
llm_request ,
227
231
response ,
228
232
[],
229
- [] ,
233
+ {} ,
230
234
)
231
235
232
236
expected_history = CacheEntry (query = HumanMessage (query ))
@@ -269,11 +273,11 @@ def test_store_conversation_history_empty_user_id():
269
273
llm_request = LLMRequest (query = "Tell me about Kubernetes" )
270
274
with pytest .raises (HTTPException , match = "Invalid user ID" ):
271
275
ols .store_conversation_history (
272
- user_id , conversation_id , llm_request , "" , [], []
276
+ user_id , conversation_id , llm_request , "" , [], {}
273
277
)
274
278
with pytest .raises (HTTPException , match = "Invalid user ID" ):
275
279
ols .store_conversation_history (
276
- user_id , conversation_id , llm_request , None , [], []
280
+ user_id , conversation_id , llm_request , None , [], {}
277
281
)
278
282
279
283
@@ -285,7 +289,7 @@ def test_store_conversation_history_improper_user_id():
285
289
llm_request = LLMRequest (query = "Tell me about Kubernetes" )
286
290
with pytest .raises (HTTPException , match = "Invalid user ID" ):
287
291
ols .store_conversation_history (
288
- user_id , conversation_id , llm_request , "" , [], []
292
+ user_id , conversation_id , llm_request , "" , [], {}
289
293
)
290
294
291
295
@@ -296,7 +300,7 @@ def test_store_conversation_history_improper_conversation_id():
296
300
llm_request = LLMRequest (query = "Tell me about Kubernetes" )
297
301
with pytest .raises (HTTPException , match = "Invalid conversation ID" ):
298
302
ols .store_conversation_history (
299
- constants .DEFAULT_USER_UID , conversation_id , llm_request , "" , [], []
303
+ constants .DEFAULT_USER_UID , conversation_id , llm_request , "" , [], {}
300
304
)
301
305
302
306
@@ -465,6 +469,7 @@ def test_query_filter_with_one_redact_filter():
465
469
llm_request = LLMRequest (query = query , conversation_id = conversation_id )
466
470
467
471
# use one custom filter
472
+ assert config .ols_config .query_filters is not None
468
473
q = Redactor (config .ols_config .query_filters )
469
474
q .regex_filters = [
470
475
RegexFilter (
@@ -488,6 +493,7 @@ def test_query_filter_with_two_redact_filters():
488
493
llm_request = LLMRequest (query = query , conversation_id = conversation_id )
489
494
490
495
# use two custom filters
496
+ assert config .ols_config .query_filters is not None
491
497
q = Redactor (config .ols_config .query_filters )
492
498
q .regex_filters = [
493
499
RegexFilter (
@@ -562,6 +568,7 @@ def test_attachments_redact_with_one_filter_defined():
562
568
]
563
569
564
570
# use two custom filters
571
+ assert config .ols_config .query_filters is not None
565
572
q = Redactor (config .ols_config .query_filters )
566
573
q .regex_filters = [
567
574
RegexFilter (
@@ -608,6 +615,7 @@ def test_attachments_redact_with_two_filters_defined():
608
615
]
609
616
610
617
# use two custom filters
618
+ assert config .ols_config .query_filters is not None
611
619
q = Redactor (config .ols_config .query_filters )
612
620
q .regex_filters = [
613
621
RegexFilter (
@@ -1106,6 +1114,8 @@ def test_consume_tokens_with_existing_quota_limiter():
1106
1114
"""Test the function consume_tokens for configured quota limiter."""
1107
1115
1108
1116
class MockQuotaLimiter :
1117
+ """Mocked quota limiter."""
1118
+
1109
1119
def consume_tokens (self , input_tokens = 0 , output_tokens = 0 , subject_id = "" ):
1110
1120
self ._input_tokens = input_tokens
1111
1121
self ._output_tokens = output_tokens
0 commit comments