def test_help(self, mock_parse_args, mock_print_help): mock_parse_args.return_value = (optparse.Values(), ['help']) oparser = optparse.OptionParser() (options, command, args) = cache_manage.parse_options(oparser, ['help']) command(options, args) self.assertEqual(1, mock_print_help.call_count)
def test_help_with_command(self, mock_parse_args): mock_parse_args.return_value = (optparse.Values(), ['help', 'list-cached']) oparser = optparse.OptionParser() (options, command, args) = cache_manage.parse_options(oparser, ['help', 'list-cached']) command(options, args)
def test_parse_options_retrieve_command(self, mock_lookup): mock_lookup.return_value = True oparser = optparse.OptionParser() cache_manage.create_options(oparser) (options, command, args) = cache_manage.parse_options(oparser, ['-p', '1212', 'list-cached']) self.assertTrue(command)
def test_help_with_redundant_command(self, mock_parse_args, mock_exit): mock_parse_args.return_value = (optparse.Values(), ['help', 'list-cached', "1"]) oparser = optparse.OptionParser() (options, command, args) = cache_manage.parse_options(oparser, ['help', 'list-cached', "1"]) command(options, args) self.assertEqual(1, mock_exit.call_count)