Esempio n. 1
0
    def test_initialize_codecommit__source_control_is_not_setup(
            self,
            log_error_mock,
            get_boolean_response_mock,
            get_region_name_mack,
            set_branch_default_for_current_environment_mock,
            set_repo_default_for_current_environment_mock,
            get_branch_interactive_mock,
            get_repository_interactive_mock,
            print_current_codecommit_settings_mock,
            region_supported_mock,
            get_source_control_mock
    ):
        source_control_mock = mock.MagicMock()
        source_control_mock.is_setup.return_value = False
        get_source_control_mock.return_value = source_control_mock

        gitops.initialize_codecommit()

        region_supported_mock.assert_not_called()
        get_boolean_response_mock.assert_not_called()
        set_repo_default_for_current_environment_mock.assert_not_called()
        set_branch_default_for_current_environment_mock.assert_not_called()
        get_repository_interactive_mock.assert_not_called()
        get_branch_interactive_mock.assert_not_called()
        print_current_codecommit_settings_mock.assert_not_called()
        log_error_mock.assert_called_once_with('Cannot setup CodeCommit because there is no Source Control setup')
Esempio n. 2
0
    def test_initialize_codecommit__region_does_not_support_codecommit(
            self,
            log_error_mock,
            get_boolean_response_mock,
            get_region_name_mock,
            set_branch_default_for_current_environment_mock,
            set_repo_default_for_current_environment_mock,
            get_branch_interactive_mock,
            get_repository_interactive_mock,
            print_current_codecommit_settings_mock,
            region_supported_mock,
            get_source_control_mock
    ):
        source_control_mock = mock.MagicMock()
        source_control_mock.is_setup.return_value = True
        get_source_control_mock.return_value = source_control_mock
        region_supported_mock.return_value = False
        get_region_name_mock.return_value = 'some-region'

        gitops.initialize_codecommit()

        region_supported_mock.assert_called_once_with()
        get_boolean_response_mock.assert_not_called()
        set_repo_default_for_current_environment_mock.assert_not_called()
        set_branch_default_for_current_environment_mock.assert_not_called()
        get_repository_interactive_mock.assert_not_called()
        get_branch_interactive_mock.assert_not_called()
        print_current_codecommit_settings_mock.assert_not_called()
        log_error_mock.assert_called_once_with('The region some-region is not supported by CodeCommit')
Esempio n. 3
0
    def test_initialize_codecommit(
            self, validate_action_mock, get_default_region_mock,
            set_branch_default_for_current_environment_mock,
            set_repo_default_for_current_environment_mock,
            get_branch_interactive_mock, get_repository_interactive_mock,
            print_current_codecommit_settings_mock, region_supported_mock,
            get_source_control_mock):
        source_control_mock = mock.MagicMock()
        source_control_mock.is_setup.return_value = True
        get_source_control_mock.return_value = source_control_mock
        region_supported_mock.return_value = True
        get_default_region_mock.return_value = 'us-west-2'
        validate_action_mock.return_value = 'y'
        get_repository_interactive_mock.return_value = 'my-repository'
        get_branch_interactive_mock.return_value = 'my-branch'

        gitops.initialize_codecommit()

        region_supported_mock.assert_called_once_with('us-west-2')
        validate_action_mock.assert_called_once_with(
            'Do you wish to continue (y/n)', 'y')
        set_repo_default_for_current_environment_mock.assert_called_once_with(
            'my-repository')
        set_branch_default_for_current_environment_mock.assert_called_once_with(
            'my-branch')
Esempio n. 4
0
    def test_initialize_codecommit(
            self,
            get_boolean_response_mock,
            get_region_name_mock,
            set_branch_default_for_current_environment_mock,
            set_repo_default_for_current_environment_mock,
            get_branch_interactive_mock,
            get_repository_interactive_mock,
            print_current_codecommit_settings_mock,
            region_supported_mock,
            get_source_control_mock
    ):
        source_control_mock = mock.MagicMock()
        source_control_mock.is_setup.return_value = True
        get_source_control_mock.return_value = source_control_mock
        region_supported_mock.return_value = True
        get_boolean_response_mock.return_value = True
        get_repository_interactive_mock.return_value = 'my-repository'
        get_branch_interactive_mock.return_value = 'my-branch'

        gitops.initialize_codecommit()

        region_supported_mock.assert_called_once_with()
        get_boolean_response_mock.assert_called_once_with(
            text='Do you wish to continue?',
            default=True)
        set_repo_default_for_current_environment_mock.assert_called_once_with('my-repository')
        set_branch_default_for_current_environment_mock.assert_called_once_with('my-branch')
Esempio n. 5
0
 def set_codecommit(self):
     gitops.initialize_codecommit()