@@ -535,6 +535,40 @@ async def test_stream_throttling_exception_from_general_exception(bedrock_client
535535 )
536536
537537
538+ @pytest .mark .asyncio
539+ async def test_stream_throttling_exception_lowercase (bedrock_client , model , messages , alist ):
540+ """Test that lowercase throttlingException is converted to ModelThrottledException."""
541+ error_message = "throttlingException: Rate exceeded for ConverseStream"
542+ bedrock_client .converse_stream .side_effect = ClientError (
543+ {"Error" : {"Message" : error_message , "Code" : "throttlingException" }}, "Any"
544+ )
545+
546+ with pytest .raises (ModelThrottledException ) as excinfo :
547+ await alist (model .stream (messages ))
548+
549+ assert error_message in str (excinfo .value )
550+ bedrock_client .converse_stream .assert_called_once_with (
551+ modelId = "m1" , messages = messages , system = [], inferenceConfig = {}
552+ )
553+
554+
555+ @pytest .mark .asyncio
556+ async def test_stream_throttling_exception_lowercase_non_streaming (bedrock_client , messages , alist ):
557+ """Test that lowercase throttlingException is converted to ModelThrottledException in non-streaming mode."""
558+ error_message = "throttlingException: Rate exceeded for Converse"
559+ bedrock_client .converse .side_effect = ClientError (
560+ {"Error" : {"Message" : error_message , "Code" : "throttlingException" }}, "Any"
561+ )
562+
563+ model = BedrockModel (model_id = "test-model" , streaming = False )
564+ with pytest .raises (ModelThrottledException ) as excinfo :
565+ await alist (model .stream (messages ))
566+
567+ assert error_message in str (excinfo .value )
568+ bedrock_client .converse .assert_called_once ()
569+ bedrock_client .converse_stream .assert_not_called ()
570+
571+
538572@pytest .mark .asyncio
539573async def test_general_exception_is_raised (bedrock_client , model , messages , alist ):
540574 error_message = "Should be raised up"
0 commit comments