def test_proceed_if_no_change_skip_prompt_at_management_group( self, deploy_template_mock, what_if_command_mock, prompt_y_n_mock): # Arrange. what_if_command_mock.return_value = WhatIfOperationResult(changes=[ WhatIfChange(resource_id='resource1', change_type=ChangeType.no_change), WhatIfChange(resource_id='resource2', change_type=ChangeType.ignore), ]) # Act. deploy_arm_template_at_management_group(cmd, mock.MagicMock(), confirm_with_what_if=True, proceed_if_no_change=True) # Assert. prompt_y_n_mock.assert_not_called() deploy_template_mock.assert_called_once()
def test_confirm_with_what_if_prompt_at_management_group( self, what_if_command_mock, prompt_y_n_mock): # Arrange. prompt_y_n_mock.return_value = False # Act. result = deploy_arm_template_at_management_group( mock.MagicMock(), confirm_with_what_if=True) # Assert. prompt_y_n_mock.assert_called_once_with( "\nAre you sure you want to execute the deployment?") self.assertIsNone(result)
def test_proceed_if_no_change_prompt_at_management_group( self, what_if_command_mock, prompt_y_n_mock): # Arrange. what_if_command_mock.return_value = WhatIfOperationResult(changes=[ WhatIfChange(resource_id='resource1', change_type=ChangeType.modify), WhatIfChange(resource_id='resource2', change_type=ChangeType.ignore), ]) prompt_y_n_mock.return_value = False # Act. result = deploy_arm_template_at_management_group( mock.MagicMock(), confirm_with_what_if=True, proceed_if_no_change=True) # Assert. prompt_y_n_mock.assert_called_once_with( "\nAre you sure you want to execute the deployment?") self.assertIsNone(result)