File tree Expand file tree Collapse file tree
src/ContentProcessor/src/tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import pytest
22from io import BytesIO
3+ from unittest .mock import patch
34from libs .azure_helper .storage_blob import StorageBlobHelper
45
56
6- @pytest .fixture
7- def mock_blob_service_client (mocker ):
8- return mocker .patch ("azure.storage.blob.BlobServiceClient" )
7+ @pytest .fixture (autouse = True )
8+ def mock_azure_credentials (mocker ):
9+ """Mock Azure credentials to prevent real authentication attempts during tests."""
10+ mocker .patch ("azure.identity.DefaultAzureCredential" )
11+ mocker .patch ("azure.identity.ManagedIdentityCredential" )
12+ mocker .patch ("helpers.azure_credential_utils.get_azure_credential" , return_value = "mock_credential" )
913
1014
1115@pytest .fixture
12- def mock_default_azure_credential (mocker ):
16+ def mock_blob_service_client (mocker ):
1317 return mocker .patch ("azure.storage.blob.BlobServiceClient" )
1418
1519
1620@pytest .fixture
17- def storage_blob_helper (mock_blob_service_client , mock_default_azure_credential ):
21+ def storage_blob_helper (mock_blob_service_client , mock_azure_credentials ):
1822 return StorageBlobHelper (
1923 account_url = "https://testaccount.blob.core.windows.net" ,
2024 container_name = "testcontainer" ,
Original file line number Diff line number Diff line change @@ -36,8 +36,10 @@ async def test_application_run(mocker):
3636 "libs.process_host.handler_process_host.HandlerHostManager"
3737 ).return_value
3838
39- # Mock the DefaultAzureCredential
39+ # Mock Azure credentials to prevent real authentication attempts
4040 mocker .patch ("azure.identity.DefaultAzureCredential" )
41+ mocker .patch ("azure.identity.ManagedIdentityCredential" )
42+ mocker .patch ("helpers.azure_credential_utils.get_azure_credential" , return_value = "mock_credential" )
4143
4244 # Mock the read_configuration method to return a complete configuration
4345 mocker .patch (
You can’t perform that action at this time.
0 commit comments