@@ -281,11 +281,13 @@ def test_request_logger_log_outputs():
281
281
)
282
282
283
283
mock_logger .info .assert_called_once ()
284
- call_args = mock_logger .info .call_args [0 ]
285
- assert "Generated response test-123" in call_args [0 ]
286
- assert "Hello, world!" in call_args [1 ]
287
- assert call_args [2 ] == [1 , 2 , 3 , 4 ]
288
- assert call_args [3 ] == "stop"
284
+ call_args = mock_logger .info .call_args .args
285
+ # logger.info(format_string, request_id, stream_info, outputs, output_token_ids, finish_reason)
286
+ assert "Generated response %s%s" in call_args [0 ]
287
+ assert call_args [1 ] == "test-123"
288
+ assert call_args [3 ] == "Hello, world!"
289
+ assert call_args [4 ] == [1 , 2 , 3 , 4 ]
290
+ assert call_args [5 ] == "stop"
289
291
290
292
291
293
def test_request_logger_log_outputs_streaming_delta ():
@@ -306,11 +308,14 @@ def test_request_logger_log_outputs_streaming_delta():
306
308
)
307
309
308
310
mock_logger .info .assert_called_once ()
309
- call_args = mock_logger .info .call_args [0 ]
310
- assert "Generated response test-456 (streaming delta)" in call_args [0 ]
311
- assert call_args [1 ] == "Hello"
312
- assert call_args [2 ] == [1 ]
313
- assert call_args [3 ] is None
311
+ call_args = mock_logger .info .call_args .args
312
+ # logger.info(format_string, request_id, stream_info, outputs, output_token_ids, finish_reason)
313
+ assert "Generated response %s%s" in call_args [0 ]
314
+ assert call_args [1 ] == "test-456"
315
+ assert call_args [2 ] == " (streaming delta)"
316
+ assert call_args [3 ] == "Hello"
317
+ assert call_args [4 ] == [1 ]
318
+ assert call_args [5 ] is None
314
319
315
320
316
321
def test_request_logger_log_outputs_streaming_complete ():
@@ -331,12 +336,14 @@ def test_request_logger_log_outputs_streaming_complete():
331
336
)
332
337
333
338
mock_logger .info .assert_called_once ()
334
- call_args = mock_logger .info .call_args [0 ]
335
- assert ("Generated response test-789 (streaming complete)"
336
- in call_args [0 ])
337
- assert call_args [1 ] == "Complete response"
338
- assert call_args [2 ] == [1 , 2 , 3 ]
339
- assert call_args [3 ] == "length"
339
+ call_args = mock_logger .info .call_args .args
340
+ # logger.info(format_string, request_id, stream_info, outputs, output_token_ids, finish_reason)
341
+ assert "Generated response %s%s" in call_args [0 ]
342
+ assert call_args [1 ] == "test-789"
343
+ assert call_args [2 ] == " (streaming complete)"
344
+ assert call_args [3 ] == "Complete response"
345
+ assert call_args [4 ] == [1 , 2 , 3 ]
346
+ assert call_args [5 ] == "length"
340
347
341
348
342
349
def test_request_logger_log_outputs_with_truncation ():
@@ -364,12 +371,12 @@ def test_request_logger_log_outputs_with_truncation():
364
371
call_args = mock_logger .info .call_args
365
372
366
373
# Check that output was truncated to first 10 characters
367
- logged_output = call_args [0 ][1 ]
374
+ logged_output = call_args [0 ][3 ]
368
375
assert logged_output == "This is a "
369
376
assert len (logged_output ) == 10
370
377
371
378
# Check that token IDs were truncated to first 10 tokens
372
- logged_token_ids = call_args [0 ][2 ]
379
+ logged_token_ids = call_args [0 ][4 ]
373
380
assert logged_token_ids == list (range (10 ))
374
381
assert len (logged_token_ids ) == 10
375
382
@@ -392,11 +399,13 @@ def test_request_logger_log_outputs_none_values():
392
399
)
393
400
394
401
mock_logger .info .assert_called_once ()
395
- call_args = mock_logger .info .call_args [0 ]
396
- assert "Generated response test-none" in call_args [0 ]
397
- assert call_args [1 ] == "Test output"
398
- assert call_args [2 ] is None
399
- assert call_args [3 ] == "stop"
402
+ call_args = mock_logger .info .call_args .args
403
+ # logger.info(format_string, request_id, stream_info, outputs, output_token_ids, finish_reason)
404
+ assert "Generated response %s%s" in call_args [0 ]
405
+ assert call_args [1 ] == "test-none"
406
+ assert call_args [3 ] == "Test output"
407
+ assert call_args [4 ] is None
408
+ assert call_args [5 ] == "stop"
400
409
401
410
402
411
def test_request_logger_log_outputs_empty_output ():
@@ -417,11 +426,13 @@ def test_request_logger_log_outputs_empty_output():
417
426
)
418
427
419
428
mock_logger .info .assert_called_once ()
420
- call_args = mock_logger .info .call_args [0 ]
421
- assert "Generated response test-empty" in call_args [0 ]
422
- assert call_args [1 ] == ""
423
- assert call_args [2 ] == []
424
- assert call_args [3 ] == "stop"
429
+ call_args = mock_logger .info .call_args .args
430
+ # logger.info(format_string, request_id, stream_info, outputs, output_token_ids, finish_reason)
431
+ assert "Generated response %s%s" in call_args [0 ]
432
+ assert call_args [1 ] == "test-empty"
433
+ assert call_args [3 ] == ""
434
+ assert call_args [4 ] == []
435
+ assert call_args [5 ] == "stop"
425
436
426
437
427
438
def test_request_logger_log_outputs_integration ():
@@ -458,5 +469,10 @@ def test_request_logger_log_outputs_integration():
458
469
input_call = mock_logger .info .call_args_list [0 ][0 ]
459
470
output_call = mock_logger .info .call_args_list [1 ][0 ]
460
471
461
- assert "Received request test-integration" in input_call [0 ]
462
- assert "Generated response test-integration" in output_call [0 ]
472
+ # Check input call: logger.info(format_string, request_id, prompt, params, ...)
473
+ assert "Received request %s" in input_call [0 ]
474
+ assert input_call [1 ] == "test-integration"
475
+
476
+ # Check output call: logger.info(format_string, request_id, stream_info, outputs, ...)
477
+ assert "Generated response %s%s" in output_call [0 ]
478
+ assert output_call [1 ] == "test-integration"
0 commit comments