|
24 | 24 |
|
25 | 25 |
|
26 | 26 | # ------------------------------ |
27 | | -# FIXTURES |
| 27 | +# FIXTURE ALIASES |
28 | 28 | # ------------------------------ |
29 | 29 |
|
30 | 30 | @pytest.fixture |
31 | | -def mock_utils(): |
32 | | - """Mock the utils module to avoid external dependencies.""" |
33 | | - with patch('infrastructures.utils') as mock_utils: |
34 | | - mock_utils.build_infrastructure_tags.return_value = {'environment': 'test', 'project': 'apim-samples'} |
35 | | - mock_utils.read_policy_xml.return_value = '<policies><inbound><base /></inbound></policies>' |
36 | | - mock_utils.determine_shared_policy_path.return_value = '/mock/path/policy.xml' |
37 | | - mock_utils.verify_infrastructure.return_value = True |
38 | | - |
39 | | - yield mock_utils |
40 | | - |
41 | | - |
42 | | -@pytest.fixture(autouse = True) |
43 | | -def mock_az(): |
44 | | - """Mock the azure_resources module used by infrastructures.""" |
45 | | - |
46 | | - with patch('infrastructures.az') as mock_az: |
47 | | - mock_az.get_infra_rg_name.return_value = 'rg-test-infrastructure-01' |
48 | | - mock_az.create_resource_group.return_value = None |
49 | | - mock_az.does_resource_group_exist.return_value = True |
50 | | - mock_az.get_account_info.return_value = ('test_user', 'test_user_id', 'test_tenant', 'test_subscription') |
51 | | - mock_az.get_unique_suffix_for_resource_group.return_value = 'abc123def456' |
52 | | - |
53 | | - # Mock the run command with proper return object |
54 | | - mock_output = Mock() |
55 | | - mock_output.success = True |
56 | | - mock_output.json_data = {'outputs': 'test'} |
57 | | - mock_output.get.return_value = 'https://test-apim.azure-api.net' |
58 | | - mock_output.getJson.return_value = ['api1', 'api2'] |
59 | | - mock_az.run.return_value = mock_output |
60 | | - |
61 | | - yield mock_az |
| 31 | +def mock_policy_fragments(sample_policy_fragments): |
| 32 | + """Alias to keep older test signatures stable.""" |
| 33 | + return sample_policy_fragments |
62 | 34 |
|
63 | | -@pytest.fixture |
64 | | -def mock_policy_fragments(): |
65 | | - """Provide mock policy fragments for testing.""" |
66 | | - return [ |
67 | | - PolicyFragment('Test-Fragment-1', '<policy>test1</policy>', 'Test fragment 1'), |
68 | | - PolicyFragment('Test-Fragment-2', '<policy>test2</policy>', 'Test fragment 2') |
69 | | - ] |
70 | 35 |
|
71 | 36 | @pytest.fixture |
72 | | -def mock_apis(): |
73 | | - """Provide mock APIs for testing.""" |
74 | | - return [ |
75 | | - API('test-api-1', 'Test API 1', '/test1', 'Test API 1 description', '<policy>api1</policy>'), |
76 | | - API('test-api-2', 'Test API 2', '/test2', 'Test API 2 description', '<policy>api2</policy>') |
77 | | - ] |
| 37 | +def mock_apis(sample_apis): |
| 38 | + """Alias to keep older test signatures stable.""" |
| 39 | + return sample_apis |
78 | 40 |
|
79 | 41 |
|
80 | 42 | # ------------------------------ |
|
0 commit comments