Skip to content

Commit 640d430

Browse files
authored
Fix test case issue (#11071)
* fix testcase issue, the issue is because we have few enviroment variables setup within CI pipeline * fix the typo within get_azure_api_key_or_token
1 parent 9b81c42 commit 640d430

File tree

3 files changed

+5
-16
lines changed

3 files changed

+5
-16
lines changed

litellm/llms/azure/common_utils.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,11 @@ class AzureAuthResponse(BaseModel):
4646
Attributes:
4747
api_key: The API key for Azure OpenAI, if provided. Can be None.
4848
azure_ad_token_provider: A callable that provides an Azure AD token. Can be None.
49-
azure_ad_token: The Azure AD token, if available. Can be None, a string token,
50-
or a callable that returns a token.
49+
azure_ad_token: The Azure AD token, if available. Can be None.
5150
"""
5251
api_key: Optional[str] = None
5352
azure_ad_token_provider: Optional[Callable[[], str]] = None
54-
azure_ad_token: Union[None, str, Callable[[], str]] = None
53+
azure_ad_token: Optional[str] = None
5554

5655

5756
def process_azure_headers(headers: Union[httpx.Headers, dict]) -> dict:
@@ -340,7 +339,7 @@ def get_azure_api_key_or_token(
340339
"Using Azure AD token provider based on Service Principal with Secret workflow for Azure Auth"
341340
)
342341
try:
343-
azure_ad_token = get_azure_ad_token_provider()
342+
azure_ad_token_provider = get_azure_ad_token_provider()
344343
except ValueError:
345344
verbose_logger.debug("Azure AD Token Provider could not be used.")
346345

tests/litellm/llms/azure/response/test_azure_responses_transformation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def test_validate_environment_with_service_principal(self, mock_azure_env_vars_n
181181
litellm_params = {}
182182

183183
# Create a token provider that returns a token when called
184-
mock_token = "service_principal_token"
184+
mock_token = lambda : "service_principal_token"
185185

186186
with patch("litellm.api_key", None):
187187
with patch("litellm.azure_key", None):
@@ -201,7 +201,7 @@ def test_validate_environment_with_service_principal(self, mock_azure_env_vars_n
201201

202202
# Verify the result contains the expected Authorization header
203203
assert "Authorization" in result
204-
assert result["Authorization"] == f"Bearer {mock_token}"
204+
assert result["Authorization"] == f"Bearer {mock_token()}"
205205

206206
def test_validate_environment_service_principal_error(self, mock_azure_env_vars_none):
207207
"""Test validate_environment when Service Principal raises ValueError"""

tests/litellm/llms/azure/test_azure_common_utils.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -908,16 +908,6 @@ def test_AzureAuthResponse_with_correct_value():
908908
assert response.azure_ad_token_provider is None
909909
assert response.azure_ad_token == fake_token
910910

911-
azure_ad_token = lambda: fake_token
912-
response = AzureAuthResponse(
913-
azure_ad_token=azure_ad_token
914-
)
915-
916-
assert response.api_key is None
917-
assert response.azure_ad_token_provider is None
918-
assert isinstance(response.azure_ad_token, Callable)
919-
assert response.azure_ad_token() == fake_token
920-
921911
def test_AzureAuthResponse_with_incorrect_value():
922912
with pytest.raises(ValidationError):
923913
response = AzureAuthResponse(

0 commit comments

Comments
 (0)