delete bash_completion in subcommand
There are two "completion" in the subcommand table: bash-completion and bash_completion. but "bash_completion" is not in help information and it is repeated with "bash-completion", so delete it. Change-Id: I0c2fb8b77b737c2ffc05dd4bb641125e88a4fde4 Closes-Bug: #1670123
This commit is contained in:
parent
f736371a63
commit
5aada5194e
@ -89,7 +89,7 @@ class SenlinShell(object):
|
||||
commands = set()
|
||||
options = set()
|
||||
for sc_str, sc in self.subcommands.items():
|
||||
if sc_str == 'bash_completion' or sc_str == 'bash-completion':
|
||||
if sc_str == 'bash-completion':
|
||||
continue
|
||||
|
||||
commands.add(sc_str)
|
||||
@ -110,14 +110,6 @@ class SenlinShell(object):
|
||||
'Without the key, profiling will not be triggered '
|
||||
'even if osprofiler is enabled on server side.'))
|
||||
|
||||
def _add_bash_completion_subparser(self, subparsers):
|
||||
subparser = subparsers.add_parser('bash_completion',
|
||||
add_help=False,
|
||||
formatter_class=HelpFormatter)
|
||||
|
||||
subparser.set_defaults(func=self.do_bash_completion)
|
||||
self.subcommands['bash_completion'] = subparser
|
||||
|
||||
def get_subcommand_parser(self, base_parser, version):
|
||||
parser = base_parser
|
||||
|
||||
@ -126,7 +118,6 @@ class SenlinShell(object):
|
||||
submodule = utils.import_versioned_module(version, 'shell')
|
||||
self._find_actions(subparsers, submodule)
|
||||
self._find_actions(subparsers, self)
|
||||
self._add_bash_completion_subparser(subparsers)
|
||||
|
||||
return parser
|
||||
|
||||
|
@ -176,7 +176,6 @@ class ShellTest(testtools.TestCase):
|
||||
'command-foo': sc1,
|
||||
'command-bar': sc2,
|
||||
'bash-completion': None,
|
||||
'bash_completion': None,
|
||||
}
|
||||
|
||||
output = self.SHELL(sh.do_bash_completion, None)
|
||||
@ -195,26 +194,9 @@ class ShellTest(testtools.TestCase):
|
||||
|
||||
self.assertEqual(0, parser.add_argument.call_count)
|
||||
|
||||
def test_add_bash_completion_subparser(self):
|
||||
sh = shell.SenlinShell()
|
||||
sh.subcommands = {}
|
||||
x_subparser = mock.Mock()
|
||||
x_subparsers = mock.Mock()
|
||||
x_subparsers.add_parser.return_value = x_subparser
|
||||
|
||||
sh._add_bash_completion_subparser(x_subparsers)
|
||||
|
||||
x_subparsers.add_parser.assert_called_once_with(
|
||||
'bash_completion', add_help=False,
|
||||
formatter_class=shell.HelpFormatter)
|
||||
self.assertEqual({'bash_completion': x_subparser}, sh.subcommands)
|
||||
x_subparser.set_defaults.assert_called_once_with(
|
||||
func=sh.do_bash_completion)
|
||||
|
||||
@mock.patch.object(utils, 'import_versioned_module')
|
||||
@mock.patch.object(shell.SenlinShell, '_find_actions')
|
||||
@mock.patch.object(shell.SenlinShell, '_add_bash_completion_subparser')
|
||||
def test_get_subcommand_parser(self, x_add, x_find, x_import):
|
||||
def test_get_subcommand_parser(self, x_find, x_import):
|
||||
x_base = mock.Mock()
|
||||
x_module = mock.Mock()
|
||||
x_import.return_value = x_module
|
||||
@ -233,7 +215,6 @@ class ShellTest(testtools.TestCase):
|
||||
]
|
||||
|
||||
x_find.assert_has_calls(find_calls)
|
||||
x_add.assert_called_once_with(x_subparsers)
|
||||
|
||||
@mock.patch.object(argparse.ArgumentParser, 'print_help')
|
||||
def test_do_help(self, mock_print):
|
||||
|
Loading…
x
Reference in New Issue
Block a user