@@ -75,7 +75,7 @@ def anthropic_client():
7575 client_kwargs = {
7676 "api_key" : api_key ,
7777 "base_url" : base_url ,
78- "timeout" : api_config .get ("timeout" , 30 ),
78+ "timeout" : api_config .get ("timeout" , 120 ),
7979 "max_retries" : api_config .get ("max_retries" , 3 ),
8080 }
8181
@@ -483,7 +483,7 @@ def test_10_complex_end2end(self, anthropic_client, test_config):
483483 # Anthropic might return empty content if tool result is sufficient
484484 # This is valid behavior - just check that we got a response
485485 assert final_response is not None
486- if len (final_response .content ) > 0 :
486+ if final_response . content and len (final_response .content ) > 0 :
487487 # If there is content, validate it
488488 assert_valid_chat_response (final_response )
489489 else :
@@ -537,17 +537,17 @@ def test_11_integration_specific_features(self, anthropic_client, test_config):
537537 @skip_if_no_api_key ("anthropic" )
538538 def test_12_error_handling_invalid_roles (self , anthropic_client , test_config ):
539539 """Test Case 12: Error handling for invalid roles"""
540- with pytest . raises ( Exception ) as exc_info :
541- anthropic_client .messages .create (
542- model = get_model ("anthropic" , "chat" ),
543- messages = INVALID_ROLE_MESSAGES ,
544- max_tokens = 100 ,
545- )
540+ # bifrost handles invalid roles internally so this test should not raise an exception
541+ response = anthropic_client .messages .create (
542+ model = get_model ("anthropic" , "chat" ),
543+ messages = INVALID_ROLE_MESSAGES ,
544+ max_tokens = 100 ,
545+ )
546546
547- # Verify the error is properly caught and contains role-related information
548- error = exc_info . value
549- assert_valid_error_response ( error , "tester " )
550- assert_error_propagation ( error , "anthropic" )
547+ # Verify the response is successful
548+ assert response is not None
549+ assert hasattr ( response , "content " )
550+ assert len ( response . content ) > 0
551551
552552 @skip_if_no_api_key ("anthropic" )
553553 def test_13_streaming (self , anthropic_client , test_config ):
@@ -561,7 +561,7 @@ def test_13_streaming(self, anthropic_client, test_config):
561561 )
562562
563563 content , chunk_count , tool_calls_detected = collect_streaming_content (
564- stream , "anthropic" , timeout = 30
564+ stream , "anthropic" , timeout = 120
565565 )
566566
567567 # Validate streaming results
@@ -579,13 +579,20 @@ def test_13_streaming(self, anthropic_client, test_config):
579579 )
580580
581581 content_tools , chunk_count_tools , tool_calls_detected_tools = (
582- collect_streaming_content (stream_with_tools , "anthropic" , timeout = 30 )
582+ collect_streaming_content (stream_with_tools , "anthropic" , timeout = 120 )
583583 )
584584
585585 # Validate tool streaming results
586586 assert chunk_count_tools > 0 , "Should receive at least one chunk with tools"
587587 assert tool_calls_detected_tools , "Should receive at least one chunk with tools"
588588
589+ @skip_if_no_api_key ("anthropic" )
590+ def test_14_list_models (self , anthropic_client , test_config ):
591+ """Test Case 14: List models"""
592+ response = anthropic_client .models .list (limit = 5 )
593+ assert response .data is not None
594+ assert len (response .data ) == 5
595+
589596
590597# Additional helper functions specific to Anthropic
591598def extract_anthropic_tool_calls (response : Any ) -> List [Dict [str , Any ]]:
0 commit comments