|
| 1 | +""" |
| 2 | +Global test configuration and fixtures for ContentProcessor tests. |
| 3 | +""" |
| 4 | +import sys |
| 5 | +import os |
| 6 | +import pytest |
| 7 | +from unittest.mock import patch, MagicMock |
| 8 | + |
| 9 | +# Add src directory to Python path for imports |
| 10 | +sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src')) |
| 11 | + |
| 12 | +pytest_plugins = ["pytest_mock"] |
| 13 | + |
| 14 | + |
| 15 | +@pytest.fixture(autouse=True, scope="session") |
| 16 | +def mock_azure_services(): |
| 17 | + """ |
| 18 | + Mock all Azure services and credentials to prevent real authentication |
| 19 | + and network calls during testing. |
| 20 | + """ |
| 21 | + with patch("azure.identity.DefaultAzureCredential") as mock_default, \ |
| 22 | + patch("azure.identity.ManagedIdentityCredential") as mock_managed, \ |
| 23 | + patch("helpers.azure_credential_utils.get_azure_credential") as mock_get_cred, \ |
| 24 | + patch("helpers.azure_credential_utils.get_azure_credential_async") as mock_get_cred_async: |
| 25 | + |
| 26 | + # Create mock credential objects |
| 27 | + mock_credential = MagicMock() |
| 28 | + mock_default.return_value = mock_credential |
| 29 | + mock_managed.return_value = mock_credential |
| 30 | + mock_get_cred.return_value = mock_credential |
| 31 | + mock_get_cred_async.return_value = mock_credential |
| 32 | + |
| 33 | + yield { |
| 34 | + "credential": mock_credential, |
| 35 | + "default": mock_default, |
| 36 | + "managed": mock_managed, |
| 37 | + "get_credential": mock_get_cred, |
| 38 | + "get_credential_async": mock_get_cred_async |
| 39 | + } |
0 commit comments