Skip to content

Commit 7979ca6

Browse files
test work flow failed fixes
1 parent 96458da commit 7979ca6

7 files changed

Lines changed: 83 additions & 69 deletions

File tree

src/ContentProcessor/conftest.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
}

src/ContentProcessor/pytest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool:pytest]
22
addopts = -v --strict-markers --disable-warnings
33
python_files = tests.py test_*.py *_tests.py
4-
testpaths = tests
4+
testpaths = src/tests
55
markers =
66
asyncio: marks tests as async

src/ContentProcessor/src/tests/azure_helper/test_storage_blob.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
pytest_plugins = ["pytest_mock"]
2-
31
import pytest
42
from io import BytesIO
53
from unittest.mock import MagicMock
Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,4 @@
11
"""
2-
Global test configuration and fixtures for ContentProcessor tests.
2+
Test configuration and fixtures for ContentProcessor tests.
33
"""
4-
import pytest
5-
from unittest.mock import patch, MagicMock
6-
7-
pytest_plugins = ["pytest_mock"]
8-
9-
10-
@pytest.fixture(autouse=True, scope="session")
11-
def mock_azure_services():
12-
"""
13-
Mock all Azure services and credentials to prevent real authentication
14-
and network calls during testing.
15-
"""
16-
with patch("azure.identity.DefaultAzureCredential") as mock_default, \
17-
patch("azure.identity.ManagedIdentityCredential") as mock_managed, \
18-
patch("helpers.azure_credential_utils.get_azure_credential") as mock_get_cred, \
19-
patch("helpers.azure_credential_utils.get_azure_credential_async") as mock_get_cred_async:
20-
21-
# Create mock credential objects
22-
mock_credential = MagicMock()
23-
mock_default.return_value = mock_credential
24-
mock_managed.return_value = mock_credential
25-
mock_get_cred.return_value = mock_credential
26-
mock_get_cred_async.return_value = mock_credential
27-
28-
yield {
29-
"credential": mock_credential,
30-
"default": mock_default,
31-
"managed": mock_managed,
32-
"get_credential": mock_get_cred,
33-
"get_credential_async": mock_get_cred_async
34-
}
4+
# Note: pytest_plugins is now defined in the top-level conftest.py

src/ContentProcessor/src/tests/test_main.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
pytest_plugins = ["pytest_mock"]
2-
31
import pytest
42
from main import Application
53

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
"""
2+
Global test configuration and fixtures for ContentProcessorAPI tests.
3+
"""
4+
import sys
5+
import os
6+
import pytest
7+
from unittest.mock import patch, MagicMock
8+
9+
# Add current directory to Python path for imports
10+
sys.path.insert(0, os.path.dirname(__file__))
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+
}
Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,4 @@
11
"""
2-
Global test configuration and fixtures for ContentProcessorAPI tests.
2+
Test configuration and fixtures for ContentProcessorAPI tests.
33
"""
4-
import pytest
5-
from unittest.mock import patch, MagicMock
6-
7-
pytest_plugins = ["pytest_mock"]
8-
9-
10-
@pytest.fixture(autouse=True, scope="session")
11-
def mock_azure_services():
12-
"""
13-
Mock all Azure services and credentials to prevent real authentication
14-
and network calls during testing.
15-
"""
16-
with patch("azure.identity.DefaultAzureCredential") as mock_default, \
17-
patch("azure.identity.ManagedIdentityCredential") as mock_managed, \
18-
patch("helpers.azure_credential_utils.get_azure_credential") as mock_get_cred, \
19-
patch("helpers.azure_credential_utils.get_azure_credential_async") as mock_get_cred_async:
20-
21-
# Create mock credential objects
22-
mock_credential = MagicMock()
23-
mock_default.return_value = mock_credential
24-
mock_managed.return_value = mock_credential
25-
mock_get_cred.return_value = mock_credential
26-
mock_get_cred_async.return_value = mock_credential
27-
28-
yield {
29-
"credential": mock_credential,
30-
"default": mock_default,
31-
"managed": mock_managed,
32-
"get_credential": mock_get_cred,
33-
"get_credential_async": mock_get_cred_async
34-
}
4+
# Note: pytest_plugins is now defined in the top-level conftest.py

0 commit comments

Comments
 (0)