Exemplo n.º 1
0
 def test_complete_top_level_args(self):
     commands = {
         'subcommands': {},
         'arguments': ['foo', 'bar']
     }
     completer = Completer(
         self.clidriver_creator.create_clidriver(commands))
     self.assert_completion(completer, 'cdp --', ['--foo', '--bar'])
Exemplo n.º 2
0
 def test_complete_service_arg_with_arg_already_used(self):
     commands = {
         'subcommands': {
             'baz': {}
         },
         'arguments': ['foo', 'bar']
     }
     completer = Completer(
         self.clidriver_creator.create_clidriver(commands))
     self.assert_completion(completer, 'cdp baz --foo --f', [])
Exemplo n.º 3
0
 def test_complete_service_arguments(self):
     commands = {
         'subcommands': {
             'foo': {}
         },
         'arguments': ['baz', 'bin']
     }
     completer = Completer(
         self.clidriver_creator.create_clidriver(commands))
     self.assert_completion(completer, 'cdp foo --', ['--baz', '--bin'])
Exemplo n.º 4
0
 def test_complete_operation_arg_when_arg_already_used(self):
     commands = {
         'subcommands': {
             'foo': {'subcommands': {
                 'bar': {'arguments': ['baz']}
             }}
         },
         'arguments': []
     }
     completer = Completer(
         self.clidriver_creator.create_clidriver(commands))
     self.assert_completion(completer, 'cdp foo bar --baz --b', [])
Exemplo n.º 5
0
 def test_complete_undocumented_command(self):
     class UndocumentedCommand(CLICommand):
         _UNDOCUMENTED = True
     commands = {
         'subcommands': {
             'foo': {},
             'bar': UndocumentedCommand()
         },
         'arguments': []
     }
     completer = Completer(
         self.clidriver_creator.create_clidriver(commands))
     self.assert_completion(completer, 'cdp ', ['foo'])
Exemplo n.º 6
0
 def test_complete_partial_service_arguments(self):
     commands = {
         'subcommands': {
             'biz': {}
         },
         'arguments': ['foo', 'bar', 'foobar', 'fubar']
     }
     completer = Completer(
         self.clidriver_creator.create_clidriver(commands))
     self.assert_completion(completer, 'cdp biz --f', [
         '--foo', '--fubar', '--foobar'])
     self.assert_completion(completer, 'cdp biz --fo', [
         '--foo', '--foobar'])
     self.assert_completion(completer, 'cdp biz --foob', ['--foobar'])
Exemplo n.º 7
0
 def test_complete_on_invalid_service(self):
     commands = {
         'subcommands': {
             'foo': {},
             'bar': {
                 'subcommands': {
                     'baz': {}
                 }
             }
         },
         'arguments': []
     }
     completer = Completer(
         self.clidriver_creator.create_clidriver(commands))
     self.assert_completion(completer, 'cdp bin', [])
Exemplo n.º 8
0
 def test_complete_positional_argument(self):
     commands = {
         'subcommands': {
             'foo': {'subcommands': {
                 'bar': {'arguments': [
                     'baz',
                     CustomArgument('bin', positional_arg=True)
                 ]}
             }}
         },
         'arguments': []
     }
     completer = Completer(
         self.clidriver_creator.create_clidriver(commands))
     self.assert_completion(completer, 'cdp foo bar --bin ', [])
     self.assert_completion(completer, 'cdp foo bar --bin blah --',
                            ['--baz'])
Exemplo n.º 9
0
 def test_complete_partial_operation_arguments(self):
     commands = {
         'subcommands': {
             'foo': {'subcommands': {
                 'bar': {'arguments': ['base', 'baz', 'air']}
             }}
         },
         'arguments': ['bin']
     }
     completer = Completer(
         self.clidriver_creator.create_clidriver(commands))
     self.assert_completion(completer, 'cdp foo bar --b', [
         '--base', '--baz', '--bin'])
     self.assert_completion(completer, 'cdp foo bar --ba', [
         '--base', '--baz'])
     self.assert_completion(completer, 'cdp foo bar --bas', ['--base'])
     self.assert_completion(completer, 'cdp foo bar --base', [])
Exemplo n.º 10
0
 def test_complete_partial_service_name(self):
     commands = {
         'subcommands': {
             'cloudfront': {},
             'cloudformation': {},
             'cloudhsm': {},
             'sts': {}
         },
         'arguments': []
     }
     completer = Completer(
         self.clidriver_creator.create_clidriver(commands))
     self.assert_completion(completer, 'cdp cloud', [
         'cloudfront', 'cloudformation', 'cloudhsm'])
     self.assert_completion(completer, 'cdp cloudf', [
         'cloudfront', 'cloudformation'])
     self.assert_completion(completer, 'cdp cloudfr', ['cloudfront'])
     self.assert_completion(completer, 'cdp cloudfront', [])
Exemplo n.º 11
0
 def test_complete_partial_service_commands(self):
     commands = {
         'subcommands': {
             'foo': {
                 'subcommands': {
                     'barb': {
                         'arguments': ['nil']
                     },
                     'baz': {},
                     'biz': {},
                     'foobar': {}
                 }
             }
         },
         'arguments': []
     }
     completer = Completer(
         self.clidriver_creator.create_clidriver(commands))
     self.assert_completion(completer, 'cdp foo b', ['barb', 'baz', 'biz'])
     self.assert_completion(completer, 'cdp foo ba', ['barb', 'baz'])
     self.assert_completion(completer, 'cdp foo bar', ['barb'])
     self.assert_completion(completer, 'cdp foo barb', [])