Esempio n. 1
0
 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)
Esempio n. 2
0
 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)
Esempio n. 3
0
 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)
Esempio n. 4
0
 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)
Esempio n. 5
0
    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)
Esempio n. 6
0
    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)
Esempio n. 7
0
 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)
Esempio n. 8
0
 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)