コード例 #1
0
ファイル: test_api.py プロジェクト: cloudbase/maas
 def test_registers_subparsers(self):
     profile_name = self.make_profile().keys()[0]
     parser = ArgumentParser()
     self.assertIsNone(parser._subparsers)
     api.register_api_commands(parser)
     self.assertIsNotNone(parser._subparsers)
     self.assertIsNotNone(parser.subparsers.choices[profile_name])
コード例 #2
0
 def test_registers_subparsers(self):
     profile_name = list(self.make_profile().keys())[0]
     parser = ArgumentParser()
     self.assertIsNone(parser._subparsers)
     api.register_api_commands(parser)
     self.assertIsNotNone(parser._subparsers)
     self.assertIsNotNone(parser.subparsers.choices[profile_name])
コード例 #3
0
ファイル: parser.py プロジェクト: deepakhajare/maas
def prepare_parser(argv):
    """Create and populate an arguments parser for the maascli command."""
    help_title, help_body = parse_docstring(api)
    parser = ArgumentParser(
        description=help_body, prog=argv[0],
        epilog="http://maas.ubuntu.com/")
    register_cli_commands(parser)
    api.register_api_commands(parser)
    return parser
コード例 #4
0
ファイル: parser.py プロジェクト: cloudbase/maas
def prepare_parser(argv):
    """Create and populate an arguments parser for the maascli command."""
    help_title, help_body = parse_docstring(api)
    parser = ArgumentParser(description=help_body,
                            prog=argv[0],
                            epilog="http://maas.ubuntu.com/")
    register_cli_commands(parser)
    api.register_api_commands(parser)
    return parser
コード例 #5
0
def prepare_parser(argv):
    """Create and populate an arguments parser for the maascli command."""
    help_title, help_body = parse_docstring(api)
    parser = ArgumentParser(description=help_body,
                            prog=os.path.basename(argv[0]),
                            epilog="http://maas.io/")
    register_cli_commands(parser)
    api.register_api_commands(parser)
    parser.add_argument('--debug',
                        action='store_true',
                        default=False,
                        help=argparse.SUPPRESS)
    return parser
コード例 #6
0
 def test_handlers_registered_using_correct_names(self):
     profile = self.make_profile()
     parser = ArgumentParser()
     api.register_api_commands(parser)
     for resource in list(profile.values())[0]["description"]["resources"]:
         for action in resource["auth"]["actions"]:
             # Profile names are matched as-is.
             [profile_name] = profile
             # Handler names are processed with handler_command_name before
             # being added to the argument parser tree.
             handler_name = handler_command_name(resource["name"])
             # Action names are processed with safe_name before being added
             # to the argument parser tree.
             action_name = safe_name(action["name"])
             # Parsing these names as command-line arguments yields an
             # options object. Its execute attribute is an instance of
             # Action (or a subclass thereof).
             options = parser.parse_args(
                 (profile_name, handler_name, action_name))
             self.assertIsInstance(options.execute, api.Action)
コード例 #7
0
ファイル: test_api.py プロジェクト: cloudbase/maas
 def test_handlers_registered_using_correct_names(self):
     profile = self.make_profile()
     parser = ArgumentParser()
     api.register_api_commands(parser)
     for resource in profile.values()[0]["description"]["resources"]:
         for action in resource["auth"]["actions"]:
             # Profile names are matched as-is.
             profile_name = profile.keys()[0]
             # Handler names are processed with handler_command_name before
             # being added to the argument parser tree.
             handler_name = handler_command_name(resource["name"])
             # Action names are processed with safe_name before being added
             # to the argument parser tree.
             action_name = safe_name(action["name"])
             # Parsing these names as command-line arguments yields an
             # options object. Its execute attribute is an instance of
             # Action (or a subclass thereof).
             options = parser.parse_args(
                 (profile_name, handler_name, action_name))
             self.assertIsInstance(options.execute, api.Action)