Skip to content

Conversation

@simonkurtz-MSFT
Copy link
Member

No description provided.

@simonkurtz-MSFT simonkurtz-MSFT self-assigned this Dec 22, 2025
@simonkurtz-MSFT simonkurtz-MSFT added the enhancement New feature or request label Dec 22, 2025
@github-actions
Copy link

github-actions bot commented Dec 22, 2025

🐍 Python 3.13 Results

Metric Status Value
Pylint Score 10.00/10
Unit Tests success
Code Coverage 📊 87%

Full Workflow Logs

@github-actions
Copy link

github-actions bot commented Dec 22, 2025

Python 3.13 Detailed Test Results

714 tests  +276   714 ✅ +276   6s ⏱️ ±0s
  1 suites ±  0     0 💤 ±  0 
  1 files   ±  0     0 ❌ ±  0 

Results for commit 7df203d. ± Comparison against base commit 36716c2.

This pull request removes 3 and adds 279 tests. Note that renamed tests count towards both.
test_infrastructures ‑ test_infrastructure_base_apis_creation
test_infrastructures ‑ test_infrastructure_base_policy_fragments_creation
test_infrastructures ‑ test_infrastructure_creation_calls_utils_functions
test_apimrequests ‑ test_multi_request_sleep_positive
test_apimrequests ‑ test_multi_request_sleep_zero
test_apimrequests ‑ test_print_response_200_invalid_json
test_apimrequests ‑ test_print_response_200_valid_json
test_apimrequests ‑ test_print_response_code_success_and_error
test_apimrequests ‑ test_subscription_key_setter_updates_and_clears_header
test_apimtypes ‑ test_output_class_basic
test_apimtypes ‑ test_output_class_non_json
test_apimtypes ‑ test_output_getJson_empty_object
test_apimtypes ‑ test_output_getJson_with_dict_value
…

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Dec 22, 2025

🐍 Python 3.14 Results

Metric Status Value
Pylint Score 10.00/10
Unit Tests success
Code Coverage 📊 87%

Full Workflow Logs

@github-actions
Copy link

github-actions bot commented Dec 22, 2025

🐍 Python 3.12 Results

Metric Status Value
Pylint Score 10.00/10
Unit Tests success
Code Coverage 📊 87%

Full Workflow Logs

@github-actions
Copy link

github-actions bot commented Dec 22, 2025

Python 3.14 Detailed Test Results

714 tests  +276   714 ✅ +276   4s ⏱️ -2s
  1 suites ±  0     0 💤 ±  0 
  1 files   ±  0     0 ❌ ±  0 

Results for commit 7df203d. ± Comparison against base commit 36716c2.

This pull request removes 3 and adds 279 tests. Note that renamed tests count towards both.
test_infrastructures ‑ test_infrastructure_base_apis_creation
test_infrastructures ‑ test_infrastructure_base_policy_fragments_creation
test_infrastructures ‑ test_infrastructure_creation_calls_utils_functions
test_apimrequests ‑ test_multi_request_sleep_positive
test_apimrequests ‑ test_multi_request_sleep_zero
test_apimrequests ‑ test_print_response_200_invalid_json
test_apimrequests ‑ test_print_response_200_valid_json
test_apimrequests ‑ test_print_response_code_success_and_error
test_apimrequests ‑ test_subscription_key_setter_updates_and_clears_header
test_apimtypes ‑ test_output_class_basic
test_apimtypes ‑ test_output_class_non_json
test_apimtypes ‑ test_output_getJson_empty_object
test_apimtypes ‑ test_output_getJson_with_dict_value
…

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Dec 22, 2025

Python 3.12 Detailed Test Results

714 tests  +276   714 ✅ +276   7s ⏱️ -1s
  1 suites ±  0     0 💤 ±  0 
  1 files   ±  0     0 ❌ ±  0 

Results for commit 7df203d. ± Comparison against base commit 36716c2.

This pull request removes 3 and adds 279 tests. Note that renamed tests count towards both.
test_infrastructures ‑ test_infrastructure_base_apis_creation
test_infrastructures ‑ test_infrastructure_base_policy_fragments_creation
test_infrastructures ‑ test_infrastructure_creation_calls_utils_functions
test_apimrequests ‑ test_multi_request_sleep_positive
test_apimrequests ‑ test_multi_request_sleep_zero
test_apimrequests ‑ test_print_response_200_invalid_json
test_apimrequests ‑ test_print_response_200_valid_json
test_apimrequests ‑ test_print_response_code_success_and_error
test_apimrequests ‑ test_subscription_key_setter_updates_and_clears_header
test_apimtypes ‑ test_output_class_basic
test_apimtypes ‑ test_output_class_non_json
test_apimtypes ‑ test_output_getJson_empty_object
test_apimtypes ‑ test_output_getJson_with_dict_value
…

♻️ This comment has been updated with latest results.

@simonkurtz-MSFT simonkurtz-MSFT force-pushed the feature/improve-test-coverage branch from 01077d0 to b8ba3cd Compare December 23, 2025 17:50
if 'cognitiveservices account list' in command:
return Output(success=False, text='List failed')
if 'apim list' in command or 'keyvault list' in command:
return Output(success=True, json_data=[])
if 'deployment group show' in command:
return Output(success=True, text='{}')
if any(x in command for x in ['cognitiveservices', 'apim', 'keyvault']):
return Output(success=True, json_data=[])
Comment on lines +3920 to +3922
return Output(success=True, json_data=[
{'name': f'cog-{i}', 'location': 'eastus'} for i in range(5)
])
Comment on lines +3924 to +3926
return Output(success=True, json_data=[
{'name': f'apim-{i}', 'location': 'westus'} for i in range(3)
])
Comment on lines +3928 to +3930
return Output(success=True, json_data=[
{'name': f'kv-{i}', 'location': 'northeurope'} for i in range(7)
])
Comment on lines +3205 to +3360
# def test_deploy_infrastructure_appgw_apim_pe_full_flow(mock_path_class, mock_chdir, mock_getcwd, mock_utils, mock_az):
# """Test full deployment flow for APPGW-APIM-PE infrastructure."""
# mock_getcwd.return_value = '/original/path'
# mock_infra_dir = Mock()
# mock_path_instance = Mock()
# mock_path_instance.parent = mock_infra_dir
# mock_path_class.return_value = mock_path_instance

# infra = infrastructures.AppGwApimPeInfrastructure(
# rg_location='eastus',
# index=1
# )

# # Mock outputs properly using Output class
# kv_check_output = Output(False, 'Not found')
# kv_create_output = Output(True, 'Created')
# cert_check_output = Output(False, 'Not found')
# cert_create_output = Output(True, 'Created')

# # Mock main deployment with proper Output object
# deploy_json = json.dumps({
# 'properties': {
# 'outputs': {
# 'appGatewayDomainName': {'value': 'test-appgw.example.com'},
# 'appgwPublicIpAddress': {'value': '40.50.60.70'}
# }
# }
# })
# deploy_output = Output(True, deploy_json)

# # Configure side effects for multiple calls
# mock_az.run.side_effect = [
# kv_check_output, kv_create_output, cert_check_output, cert_create_output,
# deploy_output
# ]

# with patch('builtins.open', MagicMock()), \
# patch('json.dumps', return_value='{"mocked": "params"}'), \
# patch('infrastructures.print_plain'), \
# patch('infrastructures.print_ok'), \
# patch('infrastructures.print_error'), \
# patch('infrastructures.print_info'), \
# patch('infrastructures.print_command'):

# result = infra.deploy_infrastructure(is_update=False)

# assert result.success is True
# assert mock_chdir.call_count == 2


# @pytest.mark.unit
# @patch('os.getcwd')
# @patch('os.chdir')
# @patch('pathlib.Path')
# def test_deploy_infrastructure_appgw_apim_internal_with_update_flag(mock_path_class, mock_chdir, mock_getcwd, mock_utils, mock_az):
# """Test APPGW-APIM (Internal) deployment with is_update flag."""
# mock_getcwd.return_value = '/original/path'
# mock_infra_dir = Mock()
# mock_path_instance = Mock()
# mock_path_instance.parent = mock_infra_dir
# mock_path_class.return_value = mock_path_instance

# infra = infrastructures.AppGwApimInfrastructure(
# rg_location='westus',
# index=2
# )

# # Mock Key Vault check (exists)
# kv_check_output = Output(True, 'Found')

# # Mock certificate check (exists)
# cert_check_output = Output(True, 'Found')

# # Mock main deployment
# deploy_json = json.dumps({
# 'properties': {
# 'outputs': {
# 'appGatewayDomainName': {'value': 'update-appgw.example.com'},
# 'appgwPublicIpAddress': {'value': '40.50.60.71'}
# }
# }
# })
# deploy_output = Output(True, deploy_json)

# mock_az.run.side_effect = [kv_check_output, cert_check_output, deploy_output]

# with patch('builtins.open', MagicMock()), \
# patch('json.dumps', return_value='{}'), \
# patch('infrastructures.print_plain'), \
# patch('infrastructures.print_ok'), \
# patch('infrastructures.print_info'), \
# patch('infrastructures.print_command'):

# result = infra.deploy_infrastructure(is_update=True)

# assert result.success is True


# @pytest.mark.unit
# @patch('os.getcwd')
# @patch('os.chdir')
# @patch('pathlib.Path')
# def test_deploy_infrastructure_appgw_failure_keyvault_creation(mock_path_class, mock_chdir, mock_getcwd, mock_utils, mock_az):
# """Test deployment failure when Key Vault creation fails."""
# mock_getcwd.return_value = '/original/path'
# mock_infra_dir = Mock()
# mock_path_instance = Mock()
# mock_path_instance.parent = mock_infra_dir
# mock_path_class.return_value = mock_path_instance

# infra = infrastructures.AppGwApimPeInfrastructure(
# rg_location='eastus',
# index=1
# )

# # Mock Key Vault check failure (doesn't exist) and creation failure
# mock_az.run.side_effect = [Output(False, 'Not found'), Output(False, 'Creation failed')]

# with patch('builtins.open', MagicMock()), \
# patch('infrastructures.print_plain'), \
# patch('infrastructures.print_error'):

# result = infra.deploy_infrastructure(is_update=False)

# assert result.success is False
# assert 'Failed to create Key Vault' in result.error_message


# @pytest.mark.unit
# @patch('os.getcwd')
# @patch('os.chdir')
# @patch('pathlib.Path')
# def test_deploy_infrastructure_appgw_failure_certificate_creation(mock_path_class, mock_chdir, mock_getcwd, mock_utils, mock_az):
# """Test deployment failure when certificate creation fails."""
# mock_getcwd.return_value = '/original/path'
# mock_infra_dir = Mock()
# mock_path_instance = Mock()
# mock_path_instance.parent = mock_infra_dir
# mock_path_class.return_value = mock_path_instance

# infra = infrastructures.AppGwApimInfrastructure(
# rg_location='eastus',
# index=1
# )

# # Mock Key Vault success but certificate creation failure
# mock_az.run.side_effect = [Output(True, 'Found'), Output(False, 'Not found'), Output(False, 'Creation failed')]

# with patch('builtins.open', MagicMock()), \
# patch('infrastructures.print_plain'), \
# patch('infrastructures.print_error'):

# result = infra.deploy_infrastructure(is_update=False)

# assert result.success is False
# assert 'Failed to create certificate' in result.error_message
Comment on lines +3402 to +3476
# def test_deploy_infrastructure_appgw_no_output_json_data(mock_path_class, mock_chdir, mock_getcwd, mock_utils, mock_az):
# """Test deployment failure when output has no json_data."""
# mock_getcwd.return_value = '/original/path'
# mock_infra_dir = Mock()
# mock_path_instance = Mock()
# mock_path_instance.parent = mock_infra_dir
# mock_path_class.return_value = mock_path_instance

# infra = infrastructures.AppGwApimInfrastructure(
# rg_location='eastus',
# index=1
# )

# # Mock Key Vault and certificate success, deployment success but no json_data
# kv_output = Output(True, 'Found')
# cert_output = Output(True, 'Found')
# deploy_output = Output(True, 'Invalid JSON')

# mock_az.run.side_effect = [kv_output, cert_output, deploy_output]

# with patch('builtins.open', MagicMock()), \
# patch('json.dumps', return_value='{}'), \
# patch('infrastructures.print_plain'), \
# patch('infrastructures.print_ok'), \
# patch('infrastructures.print_error'):

# result = infra.deploy_infrastructure(is_update=False)

# assert result.success is False


# @pytest.mark.unit
# @patch('os.getcwd')
# @patch('os.chdir')
# @patch('pathlib.Path')
# def test_deploy_infrastructure_appgw_extracts_output_values(mock_path_class, mock_chdir, mock_getcwd, mock_utils, mock_az):
# """Test that deploy_infrastructure properly extracts output values."""
# mock_getcwd.return_value = '/original/path'
# mock_infra_dir = Mock()
# mock_path_instance = Mock()
# mock_path_instance.parent = mock_infra_dir
# mock_path_class.return_value = mock_path_instance

# infra = infrastructures.AppGwApimPeInfrastructure(
# rg_location='eastus',
# index=1
# )

# # Mock outputs
# kv_output = Output(True, 'Found')
# cert_output = Output(True, 'Found')
# deploy_json = json.dumps({
# 'properties': {
# 'outputs': {
# 'appGatewayDomainName': {'value': 'my-appgw.example.com'},
# 'appgwPublicIpAddress': {'value': '1.2.3.4'}
# }
# }
# })
# deploy_output = Output(True, deploy_json)

# mock_az.run.side_effect = [kv_output, cert_output, deploy_output]

# with patch('builtins.open', MagicMock()), \
# patch('json.dumps', return_value='{}'), \
# patch('infrastructures.print_plain'), \
# patch('infrastructures.print_ok'), \
# patch('infrastructures.print_info'), \
# patch('infrastructures.print_command'):

# result = infra.deploy_infrastructure(is_update=False)

# assert result.success is True
# assert infra.appgw_domain_name == 'my-appgw.example.com'
# assert infra.appgw_public_ip == '1.2.3.4'
@simonkurtz-MSFT simonkurtz-MSFT merged commit 6200b58 into main Dec 23, 2025
10 checks passed
@simonkurtz-MSFT simonkurtz-MSFT deleted the feature/improve-test-coverage branch December 23, 2025 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants