def test_exchange_credential_custom_exchanger(auto_exchanger, auth_scheme):
  """Test that exchange_credential calls the correct (custom) exchanger."""
  # Use a custom exchanger via the initialization
  mock_exchanger = MagicMock(spec=MockCredentialExchanger)
  mock_exchanger.exchange_credential.return_value = "custom_credential"
  auto_exchanger.exchangers[AuthCredentialTypes.API_KEY] = (
      lambda: mock_exchanger
  )
  auth_credential = AuthCredential(auth_type=AuthCredentialTypes.API_KEY)

  result = auto_exchanger.exchange_credential(auth_scheme, auth_credential)

  assert result == "custom_credential"
  mock_exchanger.exchange_credential.assert_called_once_with(
      auth_scheme, auth_credential
  )
Test that exchange_credential calls the correct (custom) exchanger.
tests/unittests/tools/openapi_tool/auth/credential_exchangers/test_auto_auth_credential_exchanger.py