def test_should_print_traceback_when_completly_unexpected_exception_occurrs(self, mock_traceback, mock_exit_program, mock_parse_arguments):

        mock_parse_arguments.side_effect = Exception("WTF!")

        main()

        mock_traceback.print_exc.assert_called_with(5)
    def test_should_return_with_error_message_and_error_code_when_completly_unexpected_exception_occurrs(self, mock_traceback, mock_exit_program, mock_parse_arguments):

        mock_parse_arguments.side_effect = Exception("WTF!")

        main()

        mock_exit_program.assert_called_with('An unknown exception occurred!', return_code=5)
    def test_should_return_with_error_message_and_error_code_when_configuration_exception_occurrs(self, mock_exit_program, mock_parse_arguments):

        mock_parse_arguments.side_effect = ConfigException("We knew this could happen!")

        main()

        mock_exit_program.assert_called_with('Configuration error!', return_code=3)
    def test_should_return_with_error_message_and_error_code_when_user_interrupts_execution(self, mock_exit_program, mock_parse_arguments):

        mock_parse_arguments.side_effect = KeyboardInterrupt()

        main()

        mock_exit_program.assert_called_with('Execution interrupted by user!', return_code=7)
    def test_should_return_with_success_message_and_return_code_zero_when_everything_works_as_expected(self, mock_exit_program, mock_parse_arguments, mock_initialize_configuration, mock_initialize_logging_to_console, mock_extract_repository_url_and_revision_from_arguments, mock_initialize_logging_to_syslog, mock_start_measuring_time, mock_log_additional_information, mock_start_building_configuration_rpms):

        mock_extract_repository_url_and_revision_from_arguments.return_value = ('repository-url', '123')

        main()

        mock_exit_program.assert_called_with("Success.", return_code=0)
Example #6
0
    def test_should_return_with_error_message_and_error_code_when_user_interrupts_execution(
            self, mock_exit_program, mock_parse_arguments):

        mock_parse_arguments.side_effect = KeyboardInterrupt()

        main()

        mock_exit_program.assert_called_with('Execution interrupted by user!',
                                             return_code=7)
Example #7
0
    def test_should_return_with_error_message_and_error_code_when_completly_unexpected_exception_occurrs(
            self, mock_traceback, mock_exit_program, mock_parse_arguments):

        mock_parse_arguments.side_effect = Exception("WTF!")

        main()

        mock_exit_program.assert_called_with('An unknown exception occurred!',
                                             return_code=5)
Example #8
0
    def test_should_return_with_error_message_and_error_code_when_configuration_exception_occurrs(
            self, mock_exit_program, mock_parse_arguments):

        mock_parse_arguments.side_effect = ConfigurationException(
            "We knew this could happen!")

        main()

        mock_exit_program.assert_called_with('Configuration error!',
                                             return_code=3)
    def test_should_print_traceback_when_completly_unexpected_exception_occurrs(self, mock_traceback, mock_exit_program, mock_parse_arguments, mock_logger):

        mock_traceback.format_exc.return_value = 'stacktrace line1\nline2\nline3\n'
        mock_parse_arguments.side_effect = Exception("WTF!")

        main()

        mock_traceback.format_exc.assert_called_with(5)
        self.assertEqual([call('stacktrace line1'),
                          call('line2'),
                          call('line3'),
                          call('')],
                         mock_logger.error.call_args_list)
Example #10
0
    def test_should_return_with_success_message_and_return_code_zero_when_everything_works_as_expected(
            self, mock_exit_program, mock_parse_arguments,
            mock_initialize_configuration, mock_initialize_logging_to_console,
            mock_extract_repository_url_and_revision_from_arguments,
            mock_initialize_logging_to_syslog, mock_start_measuring_time,
            mock_log_additional_information,
            mock_start_building_configuration_rpms):

        mock_extract_repository_url_and_revision_from_arguments.return_value = (
            'repository-url', '123')

        main()

        mock_exit_program.assert_called_with("Success.", return_code=0)
Example #11
0
    def test_should_print_traceback_when_completly_unexpected_exception_occurrs(
            self, mock_traceback, mock_exit_program, mock_parse_arguments,
            mock_logger):

        mock_traceback.format_exc.return_value = 'stacktrace line1\nline2\nline3\n'
        mock_parse_arguments.side_effect = Exception("WTF!")

        main()

        mock_traceback.format_exc.assert_called_with(5)
        self.assertEqual(
            [call('stacktrace line1'),
             call('line2'),
             call('line3'),
             call('')], mock_logger.error.call_args_list)
#   yadt-config-rpm-maker
#   Copyright (C) 2011-2013 Immobilien Scout GmbH
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.

from config_rpm_maker import main

if __name__ == "__main__":
    main()
Example #13
0
#   yadt-config-rpm-maker
#   Copyright (C) 2011-2013 Immobilien Scout GmbH
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.


from config_rpm_maker import main


if __name__ == "__main__":
    main()