@@ -526,12 +526,15 @@ def test_set_config_custom_instance_name(self):
526526
527527 set_aicore_config (instance_name = instance_name )
528528
529- # Verify instance_name was passed to _get_secret calls
530- # The _get_secret function is called without instance_name parameter
531- # because set_aicore_config doesn't pass it (it uses default)
532- # So we just verify _get_base_url received the instance_name
529+ # Verify instance_name was passed to _get_aicore_base_url
533530 mock_get_base_url .assert_called_with (instance_name )
534531
532+ # Verify instance_name was passed to all _get_secret calls
533+ for c in mock_get_secret .call_args_list :
534+ assert c .kwargs .get ("instance_name" ) == instance_name , (
535+ f"_get_secret call for { c .args [0 ]} missing instance_name={ instance_name } "
536+ )
537+
535538 def test_set_config_calls_get_secret_with_correct_parameters (self ):
536539 """Test that _get_secret is called with correct parameters for each secret."""
537540 with patch ("sap_cloud_sdk.aicore._get_secret" ) as mock_get_secret , patch (
@@ -542,22 +545,21 @@ def test_set_config_calls_get_secret_with_correct_parameters(self):
542545
543546 set_aicore_config ()
544547
545- # Verify _get_secret was called with correct parameters
546- calls = mock_get_secret .call_args_list
547- assert any (
548- call [0 ][0 ] == "AICORE_CLIENT_ID" and call [0 ][1 ] == "clientid"
549- for call in calls
548+ default_instance = "aicore-instance"
549+ # Verify _get_secret was called with correct parameters including instance_name
550+ mock_get_secret .assert_any_call (
551+ "AICORE_CLIENT_ID" , "clientid" , instance_name = default_instance
550552 )
551- assert any (
552- call [0 ][0 ] == "AICORE_CLIENT_SECRET" and call [0 ][1 ] == "clientsecret"
553- for call in calls
553+ mock_get_secret .assert_any_call (
554+ "AICORE_CLIENT_SECRET" , "clientsecret" , instance_name = default_instance
554555 )
555- assert any (
556- call [ 0 ][ 0 ] == "AICORE_AUTH_URL" and call [ 0 ][ 1 ] == "url" for call in calls
556+ mock_get_secret . assert_any_call (
557+ "AICORE_AUTH_URL" , "url" , instance_name = default_instance
557558 )
558- assert any (
559- call [0 ][0 ] == "AICORE_RESOURCE_GROUP" and call [1 ].get ("default" ) == "default"
560- for call in calls
559+ mock_get_secret .assert_any_call (
560+ "AICORE_RESOURCE_GROUP" ,
561+ default = "default" ,
562+ instance_name = default_instance ,
561563 )
562564
563565 def test_set_config_logs_configuration (self ):
0 commit comments