From 76df64954d468e00197b8e26f685f51ce096adb0 Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Wed, 13 Aug 2008 02:00:31 +0000 Subject: [PATCH] 135: Added unit test for CLI dictoinary interface --- ipalib/tests/test_cli.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ipalib/tests/test_cli.py b/ipalib/tests/test_cli.py index c523e4e86..7892227d1 100644 --- a/ipalib/tests/test_cli.py +++ b/ipalib/tests/test_cli.py @@ -106,3 +106,19 @@ class test_CLI(ClassChecker): assert o.mcl is None o.finalize() assert o.mcl == 6 # len('cmd_99') + + def test_dict(self): + """ + Tests the `__contains__` and `__getitem__` methods. + """ + cnt = 25 + api = DummyAPI(cnt) + assert len(api.cmd) == cnt + o = self.cls(api) + o.finalize() + for cmd in api.cmd: + key = cli.to_cli(cmd.name) + assert key in o + assert o[key] is cmd + assert cmd.name not in o + raises(KeyError, getitem, o, cmd.name)