-
Notifications
You must be signed in to change notification settings - Fork 14
Updated Python Tests #113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated Python Tests #113
Conversation
🐍 Python 3.13 Results
|
Python 3.13 Detailed Test Results714 tests +276 714 ✅ +276 6s ⏱️ ±0s 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.♻️ This comment has been updated with latest results. |
🐍 Python 3.14 Results
|
🐍 Python 3.12 Results
|
Python 3.14 Detailed Test Results714 tests +276 714 ✅ +276 4s ⏱️ -2s 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.♻️ This comment has been updated with latest results. |
Python 3.12 Detailed Test Results714 tests +276 714 ✅ +276 7s ⏱️ -1s 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.♻️ This comment has been updated with latest results. |
01077d0 to
b8ba3cd
Compare
| 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=[]) |
| return Output(success=True, json_data=[ | ||
| {'name': f'cog-{i}', 'location': 'eastus'} for i in range(5) | ||
| ]) |
| return Output(success=True, json_data=[ | ||
| {'name': f'apim-{i}', 'location': 'westus'} for i in range(3) | ||
| ]) |
| return Output(success=True, json_data=[ | ||
| {'name': f'kv-{i}', 'location': 'northeurope'} for i in range(7) | ||
| ]) |
| # 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 |
| # 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' |
No description provided.