Skip to content
22 changes: 11 additions & 11 deletions tests/Test-Matrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

**Date / time**: __________________

| Sample / Infrastructure | SIMPLE APIM | APIM ACA | AFD APIM PE | App Gateway APIM ACA |
|:----------------------------|-----------------------------|-----------------------------|-----------------------------|-----------------------------|
| **INFRASTRUCTURE** | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container |
| **authX** | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container |
| **authX-pro** | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container |
| **azure-maps** | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container |
| **general** | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container |
| **load-balancing** | **N/A** | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container |
| **oauth-3rd-party** | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container |
| **secure-blob-access** | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container |
| **INFRASTRUCTURE clean-up** | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container |
| Sample / Infrastructure | SIMPLE APIM | APIM ACA | AFD APIM PE | App Gateway APIM ACA | App Gateway APIM PE |
|:----------------------------|-----------------------------|-----------------------------|-----------------------------|-----------------------------|-----------------------------|
| **INFRASTRUCTURE** | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container |
| **authX** | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container |
| **authX-pro** | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container |
| **azure-maps** | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container |
| **general** | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container |
| **load-balancing** | **N/A** | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container |
| **oauth-3rd-party** | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container |
| **secure-blob-access** | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container |
| **INFRASTRUCTURE clean-up** | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container | ▢ Local<br>▢ Dev Container |
93 changes: 93 additions & 0 deletions tests/python/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@
# Add the shared/python directory to the Python path for all tests
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../shared/python')))

# Add the tests/python directory to import test_helpers
sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))

# APIM Samples imports
# pylint: disable=wrong-import-position
from test_helpers import (
create_mock_http_response,
create_mock_output,
create_sample_apis,
create_sample_policy_fragments,
get_sample_infrastructure_params,
MockApimRequestsPatches,
MockInfrastructuresPatches
)


# ------------------------------
# SHARED FIXTURES
Expand All @@ -34,3 +49,81 @@ def sample_test_data() -> dict[str, Any]:
'test_resource_group': 'rg-test-apim-01',
'test_location': 'eastus2'
}


# ------------------------------
# MOCK FIXTURES
# ------------------------------

@pytest.fixture(autouse=True)
def infrastructures_patches():
"""Automatically patch infrastructures dependencies for tests."""
with MockInfrastructuresPatches() as patches:
yield patches


@pytest.fixture
def mock_utils(infrastructures_patches):
"""Return the patched utils module for infrastructures tests."""
return infrastructures_patches.utils


@pytest.fixture
def mock_az(infrastructures_patches):
"""Return the patched azure_resources module for infrastructures tests."""
return infrastructures_patches.az


@pytest.fixture
def mock_az_success():
"""Pre-configured successful Azure CLI output."""
return create_mock_output(success=True, json_data={'result': 'success'})


@pytest.fixture
def mock_az_failure():
"""Pre-configured failed Azure CLI output."""
return create_mock_output(success=False, text='Error message')


@pytest.fixture
def sample_policy_fragments():
"""Provide sample policy fragments for testing."""
return create_sample_policy_fragments(count=2)


@pytest.fixture
def sample_apis():
"""Provide sample APIs for testing."""
return create_sample_apis(count=2)


@pytest.fixture
def sample_infrastructure_params() -> dict[str, Any]:
"""Provide common infrastructure parameters."""
return get_sample_infrastructure_params()


@pytest.fixture
def mock_http_response_200():
"""Pre-configured successful HTTP response."""
return create_mock_http_response(
status_code=200,
json_data={'result': 'ok'}
)


@pytest.fixture
def mock_http_response_error():
"""Pre-configured error HTTP response."""
return create_mock_http_response(
status_code=500,
text='Internal Server Error'
)


@pytest.fixture
def apimrequests_patches():
"""Provide common apimrequests patches for HTTP tests."""
with MockApimRequestsPatches() as patches:
yield patches
Loading
Loading