def testDiscovery(self):
    # Check built-in
    search_paths = [os.path.join(util.get_anvil_path(), 'commands')]
    commands = manage.discover_commands(search_paths)
    self.assertTrue(commands.has_key('build'))
    self.assertIsInstance(commands['build'], ManageCommand)

    # Check custom
    commands = manage.discover_commands(
        [os.path.join(self.root_path, 'commands')])
    self.assertTrue(commands.has_key('test_command'))
    test_command = commands['test_command']
    self.assertIsInstance(test_command, ManageCommand)
    args = test_command.create_argument_parser()
    parsed_args = args.parse_args([])
    cwd = os.getcwd()
    self.assertEqual(commands['test_command'].execute(parsed_args, cwd), 123)

    # Duplicate command names/etc
    with self.assertRaises(KeyError):
      manage.discover_commands([os.path.join(self.root_path, 'bad_commands')])
 def testUsage(self):
   search_paths = [os.path.join(util.get_anvil_path(), 'commands')]
   commands = manage.discover_commands(search_paths)
   self.assertNotEqual(len(manage.usage(commands)), 0)