mirror of
https://github.com/tiennm99/litellm.git
synced 2026-08-07 06:29:41 +00:00
test: clear env var before running test
This commit is contained in:
@@ -133,7 +133,13 @@ def test_initialize_with_tenant_credentials(setup_mocks):
|
||||
assert "azure_ad_token_provider" in result
|
||||
|
||||
|
||||
def test_initialize_with_username_password(setup_mocks):
|
||||
def test_initialize_with_username_password(monkeypatch, setup_mocks):
|
||||
monkeypatch.delenv("AZURE_TENANT_ID", raising=False)
|
||||
monkeypatch.delenv("AZURE_CLIENT_ID", raising=False)
|
||||
monkeypatch.delenv("AZURE_CLIENT_SECRET", raising=False)
|
||||
monkeypatch.delenv("AZURE_USERNAME", raising=False)
|
||||
monkeypatch.delenv("AZURE_PASSWORD", raising=False)
|
||||
|
||||
# Test with azure_username, azure_password, and client_id provided
|
||||
result = BaseAzureLLM().initialize_azure_sdk_client(
|
||||
litellm_params={
|
||||
@@ -148,6 +154,14 @@ def test_initialize_with_username_password(setup_mocks):
|
||||
is_async=False,
|
||||
)
|
||||
|
||||
# Print the call arguments for debugging
|
||||
print("\nDebug - Call arguments for all mocks:")
|
||||
print("username_password_token:", setup_mocks["username_password_token"].call_args)
|
||||
print("entra_token:", setup_mocks["entra_token"].call_args)
|
||||
print("oidc_token:", setup_mocks["oidc_token"].call_args)
|
||||
print("token_provider:", setup_mocks["token_provider"].call_args)
|
||||
print("\nResult:", result)
|
||||
|
||||
# Verify that get_azure_ad_token_from_username_password was called
|
||||
setup_mocks["username_password_token"].assert_called_once_with(
|
||||
azure_username="test-username",
|
||||
@@ -260,6 +274,7 @@ def test_initialize_with_oidc_token_no_credentials(setup_mocks, monkeypatch):
|
||||
# Verify expected result
|
||||
assert result["azure_ad_token"] == "mock-oidc-token"
|
||||
|
||||
|
||||
def test_initialize_with_ad_token_provider(setup_mocks, monkeypatch):
|
||||
# Clear environment variables
|
||||
monkeypatch.delenv("AZURE_CLIENT_ID", raising=False)
|
||||
|
||||
Reference in New Issue
Block a user