diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2008-08-13 01:52:17 +0000 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2008-08-13 01:52:17 +0000 |
commit | 0b5efa2a62623e09c7e8e5e97e0feafbc5e19823 (patch) | |
tree | 8c13150c8a0cf0bac69c340ae5358e2cb624330c /ipalib/tests/test_cli.py | |
parent | c0b5069fa07889496786523c46b5b15181c26fee (diff) | |
download | freeipa.git-0b5efa2a62623e09c7e8e5e97e0feafbc5e19823.tar.gz freeipa.git-0b5efa2a62623e09c7e8e5e97e0feafbc5e19823.tar.xz freeipa.git-0b5efa2a62623e09c7e8e5e97e0feafbc5e19823.zip |
134: Added CLI.mcl (Max Command Length) property; added corresponding unit tests
Diffstat (limited to 'ipalib/tests/test_cli.py')
-rw-r--r-- | ipalib/tests/test_cli.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/ipalib/tests/test_cli.py b/ipalib/tests/test_cli.py index d56a4b19..c523e4e8 100644 --- a/ipalib/tests/test_cli.py +++ b/ipalib/tests/test_cli.py @@ -37,6 +37,35 @@ def test_from_cli(): assert f('user-add') == 'user_add' +def get_cmd_name(i): + return 'cmd_%d' % i + +class DummyCmd(object): + def __init__(self, name): + self.__name = name + + def __get_name(self): + return self.__name + name = property(__get_name) + +class DummyAPI(object): + def __init__(self, cnt): + self.__cmd = tuple(self.__cmd_iter(cnt)) + + def __get_cmd(self): + return self.__cmd + cmd = property(__get_cmd) + + def __cmd_iter(self, cnt): + for i in xrange(cnt): + yield DummyCmd(get_cmd_name(i)) + + def finalize(self): + pass + + + + class test_CLI(ClassChecker): """ Tests the `CLI` class. @@ -65,3 +94,15 @@ class test_CLI(ClassChecker): ) args = tuple('--%s=%s' % (cli.to_cli(k), v) for (k,v) in kw.items()) assert dict(o.parse_kw(args)) == kw + + def test_mcl(self): + """ + Tests the `mcl` (Max Command Length) property . + """ + cnt = 100 + api = DummyAPI(cnt) + len(api.cmd) == cnt + o = self.cls(api) + assert o.mcl is None + o.finalize() + assert o.mcl == 6 # len('cmd_99') |