mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
146: Removed CLI.parse_kw() method and corresponding unit tests
This commit is contained in:
@@ -98,19 +98,8 @@ class CLI(object):
|
||||
self.run_cmd(cmd, sys.argv[2:])
|
||||
|
||||
def run_cmd(self, cmd, given):
|
||||
print self.parse(given)
|
||||
sys.exit(0)
|
||||
kw = dict(self.parse_kw(args))
|
||||
self[cmd](**kw)
|
||||
|
||||
def parse_kw(self, args):
|
||||
for arg in args:
|
||||
m = re.match(r'^--([a-z][-a-z0-9]*)=(.+)$', arg)
|
||||
if m is not None:
|
||||
yield (
|
||||
from_cli(m.group(1)),
|
||||
m.group(2),
|
||||
)
|
||||
(args, kw) = self.parse(given)
|
||||
self[cmd](*args, **kw)
|
||||
|
||||
def parse(self, given):
|
||||
args = []
|
||||
@@ -123,7 +112,6 @@ class CLI(object):
|
||||
args.append(g)
|
||||
return (args, kw)
|
||||
|
||||
|
||||
def __get_mcl(self):
|
||||
"""
|
||||
Returns the Max Command Length.
|
||||
|
||||
@@ -86,18 +86,6 @@ class test_CLI(ClassChecker):
|
||||
o = self.cls(api)
|
||||
assert read_only(o, 'api') is api
|
||||
|
||||
def test_parse_kw(self):
|
||||
"""
|
||||
Tests the `parse_kw` method.
|
||||
"""
|
||||
o = self.cls(None)
|
||||
kw = dict(
|
||||
hello='world',
|
||||
how_are='you',
|
||||
)
|
||||
args = tuple('--%s=%s' % (cli.to_cli(k), v) for (k,v) in kw.items())
|
||||
assert dict(o.parse_kw(args)) == kw
|
||||
|
||||
def test_parse(self):
|
||||
"""
|
||||
Tests the `parse` method.
|
||||
@@ -114,7 +102,6 @@ class test_CLI(ClassChecker):
|
||||
assert o.parse(args + opts) == (args, kw)
|
||||
assert o.parse(opts + args) == (args, kw)
|
||||
|
||||
|
||||
def test_mcl(self):
|
||||
"""
|
||||
Tests the `mcl` (Max Command Length) property .
|
||||
|
||||
Reference in New Issue
Block a user