@@ -1187,59 +1187,6 @@ async def test_bedrock_guardrail_uses_default_endpoint_when_no_custom_set(monkey
1187
1187
1188
1188
print (f"Default endpoint test passed. URL: { prepped_request .url } " )
1189
1189
1190
-
1191
- @pytest .mark .asyncio
1192
- async def test_bedrock_guardrail_parameter_takes_precedence_over_env (monkeypatch ):
1193
- """Test that aws_bedrock_runtime_endpoint parameter takes precedence over environment variable
1194
-
1195
- This test verifies the corrected behavior where the parameter should take precedence
1196
- over the environment variable, consistent with the endpoint_url logic.
1197
- """
1198
-
1199
- param_endpoint = "https://param-bedrock.example.com"
1200
- env_endpoint = "https://env-bedrock.example.com"
1201
-
1202
- # Set environment variable
1203
- monkeypatch .setenv ("AWS_BEDROCK_RUNTIME_ENDPOINT" , env_endpoint )
1204
-
1205
- # Create guardrail with explicit aws_bedrock_runtime_endpoint
1206
- guardrail = BedrockGuardrail (
1207
- guardrailIdentifier = "test-guardrail" ,
1208
- guardrailVersion = "DRAFT" ,
1209
- aws_bedrock_runtime_endpoint = param_endpoint ,
1210
- )
1211
-
1212
- # Mock credentials
1213
- mock_credentials = MagicMock ()
1214
- mock_credentials .access_key = "test-access-key"
1215
- mock_credentials .secret_key = "test-secret-key"
1216
- mock_credentials .token = None
1217
-
1218
- # Test data
1219
- data = {"source" : "INPUT" , "content" : [{"text" : {"text" : "test content" }}]}
1220
- optional_params = {}
1221
- aws_region_name = "us-east-1"
1222
-
1223
- # Mock the _load_credentials method
1224
- with patch .object (
1225
- guardrail , "_load_credentials" , return_value = (mock_credentials , aws_region_name )
1226
- ):
1227
- # Call _prepare_request which internally calls get_runtime_endpoint
1228
- prepped_request = guardrail ._prepare_request (
1229
- credentials = mock_credentials ,
1230
- data = data ,
1231
- optional_params = optional_params ,
1232
- aws_region_name = aws_region_name ,
1233
- )
1234
-
1235
- # Verify that the parameter takes precedence over environment variable
1236
- expected_url = f"{ param_endpoint } /guardrail/{ guardrail .guardrailIdentifier } /version/{ guardrail .guardrailVersion } /apply"
1237
- assert (
1238
- prepped_request .url == expected_url
1239
- ), f"Expected parameter endpoint to take precedence. Got: { prepped_request .url } "
1240
-
1241
- print (f"Parameter precedence test passed. URL: { prepped_request .url } " )
1242
-
1243
1190
@pytest .mark .asyncio
1244
1191
async def test_bedrock_guardrail_200_with_exception_in_output_raises_and_logs_failure ():
1245
1192
"""
0 commit comments