예제 #1
0
    def test_should_not_call_anything_when_no_execution_option_configured(
            self, mock_execute_command, mock_commit, mock_exists, mock_exit):

        mock_exists.return_value = False

        commit_changes(['/usr/local/bin/commit'])

        self.assertEqual([], mock_execute_command.call_args_list)
예제 #2
0
    def test_should_execute_motivation_command_when_activated(
            self, mock_load_configuration, mock_execute_motivation_command, mock_execute_command, mock_commit,
            mock_exists, mock_exit):

        mock_configuration = Mock()
        mock_configuration.execute_before = False
        mock_configuration.execute_before_commit = False
        mock_configuration.motivate_me = True
        mock_load_configuration.return_value = mock_configuration

        commit_changes(['/usr/local/bin/commit'])

        mock_execute_motivation_command.assert_called_with(mock_configuration)
예제 #3
0
    def test_should_not_execute_motivation_command_when_not_activated(
            self, mock_load_configuration, mock_execute_motivation_command, mock_execute_command, mock_commit,
            mock_exists, mock_exit):

        mock_configuration = Mock()
        mock_configuration.execute_before = False
        mock_configuration.execute_before_commit = False
        mock_configuration.motivate_me = False
        mock_load_configuration.return_value = mock_configuration

        commit_changes(['/usr/local/bin/commit'])

        self.assertEqual([], mock_execute_motivation_command.call_args_list)
예제 #4
0
    def test_should_call_command_when_execute_before_commit_option_is_configured(self, mock_execute_command, mock_config_parser_class, mock_commit, mock_exists, mock_exit):
        mock_exists.return_value = True
        mock_config_parser = Mock()

        def has_side_effect(section, option):
            if section == "COMMIT" and option == "execute_before":
                return True
            return False
        mock_config_parser.has.side_effect = has_side_effect

        def get_side_effect(section, option):
            if section == "COMMIT" and option == "execute_before":
                return "command"
        mock_config_parser.get.side_effect = get_side_effect

        mock_config_parser_class.return_value = mock_config_parser

        commit_changes(['/usr/local/bin/commit'])

        self.assertEqual(call('command'), mock_execute_command.call_args)
예제 #5
0
    def test_should_call_command_with_arguments_when_execute_before_commit_option_is_configured(
            self, mock_execute_motivation_command, mock_config_parser_class, mock_execute_command, mock_commit,
            mock_exists, mock_exit):

        mock_exists.return_value = True
        mock_config_parser = Mock()

        def has_side_effect(section, option):
            if section == "COMMIT" and option == "execute_before":
                return True
            return False
        mock_config_parser.has.side_effect = has_side_effect

        def get_side_effect(section, option):
            if section == "COMMIT" and option == "execute_before":
                return "command --with --arguments"
        mock_config_parser.get.side_effect = get_side_effect

        mock_config_parser_class.return_value = mock_config_parser

        commit_changes(['/usr/local/bin/commit'])

        mock_execute_command.assert_called_with('command', '--with', '--arguments')
예제 #6
0
    def test_should_call_commit_with_arguments(
            self, mock_execute_motivation_command, mock_execute_command, mock_commit, mock_exists, mock_exit):

        commit_changes(['/usr/local/bin/commit'])

        mock_commit.assert_called_with(['/usr/local/bin/commit'])
예제 #7
0
    def skip_test_should_call_commit_with_arguments(self, mock_execute_command, mock_commit, mock_exists, mock_exit):

        commit_changes(['/usr/local/bin/commit'])

        self.assertEqual(call(['/usr/local/bin/commit']), mock_commit.call_args)