def test__main_Should_PrintUsage_When_MissingArgumentError( self, get_parser_patch, logger_patch, *patches): parser_mock = Mock() parser_mock.parse_args.side_effect = [MissingArgumentError('error')] get_parser_patch.return_value = parser_mock main() parser_mock.print_usage.assert_called_once_with() logger_patch.error.assert_called()
def test__main_Should_Exit_When_Exception(self, get_parser_patch, logger_patch, sys_patch, *patches): parser_mock = Mock() parser_mock.parse_args.side_effect = [Exception('error')] get_parser_patch.return_value = parser_mock main() logger_patch.error.assert_called() sys_patch.exit.assert_called_once_with(-1)
def test__main_Should_CallExpected_When_NoRepos( self, prune_prerelease_tags_patch, get_client_patch, get_parser_patch, *patches): parser_mock = Mock() parser_mock.parse_args.return_value = Namespace(report=None, processes=None, version=None) get_parser_patch.return_value = parser_mock client_mock = Mock() get_client_patch.return_value = client_mock main() prune_prerelease_tags_patch.assert_not_called()
def test__main_Should_CallExpected_When_NoReport_AndProcessesVersion( self, initiate_multiprocess_patch, get_client_patch, get_parser_patch, write_report_patch, *patches): parser_mock = Mock() parser_mock.parse_args.return_value = Namespace(report=False, processes=2, version=True) get_parser_patch.return_value = parser_mock client_mock = Mock() get_client_patch.return_value = client_mock main() write_report_patch.assert_not_called()
def test__main_Should_CallExpected_When_ReportVersionNoProcesses( self, initiate_multiprocess_patch, get_client_patch, get_parser_patch, write_report_patch, *patches): parser_mock = Mock() parser_mock.parse_args.return_value = Namespace(report=True, processes=None, version=True) get_parser_patch.return_value = parser_mock client_mock = Mock() get_client_patch.return_value = client_mock main() write_report_patch.assert_called_once()
def test__main_Should_CallExpected_When_NoReportNoProcesses_WithVersion( self, prune_version_tags, get_client_patch, get_parser_patch, *patches): parser_mock = Mock() parser_mock.parse_args.return_value = Namespace(report=None, processes=None, version='<1.1.1') get_parser_patch.return_value = parser_mock client_mock = Mock() get_client_patch.return_value = client_mock main() prune_version_tags.assert_called_once_with( client_mock, ['repo1'], parser_mock.parse_args.return_value)