summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2008-07-20 03:48:36 +0000
committerJason Gerard DeRose <jderose@redhat.com>2008-07-20 03:48:36 +0000
commitc2df39156979ea5a01901b97504c1de276364dfc (patch)
tree1f0ff85090d7824907f82709c8280b6003251b9d
parent370282819d7839e6e5091c019d6ff1b606add066 (diff)
downloadfreeipa-c2df39156979ea5a01901b97504c1de276364dfc.tar.gz
freeipa-c2df39156979ea5a01901b97504c1de276364dfc.tar.xz
freeipa-c2df39156979ea5a01901b97504c1de276364dfc.zip
14: Added Named.cli property that returns name.replace('_', '-'); Named.doc property now does a strip() to make it more user-friendly; added test_Named unit tests which somehow got dropped, uppdated with new Named properties
-rw-r--r--ipalib/base.py6
-rw-r--r--ipalib/tests/test_base.py11
2 files changed, 16 insertions, 1 deletions
diff --git a/ipalib/base.py b/ipalib/base.py
index 2769efd3b..ece446cff 100644
--- a/ipalib/base.py
+++ b/ipalib/base.py
@@ -132,8 +132,12 @@ class Named(object):
return self.__class__.__name__
name = property(__get_name)
+ def __get_cli(self):
+ return self.name.replace('_', '-')
+ cli = property(__get_cli)
+
def __get_doc(self):
- return self.__class__.__doc__
+ return self.__class__.__doc__.strip()
doc = property(__get_doc)
diff --git a/ipalib/tests/test_base.py b/ipalib/tests/test_base.py
index 818b7713a..0dfd3438f 100644
--- a/ipalib/tests/test_base.py
+++ b/ipalib/tests/test_base.py
@@ -183,6 +183,17 @@ class test_NameSpace:
assert len(kw) == len(ns) == 3
+def test_Named():
+ class named_class(base.Named):
+ """
+ This class is so introspective!
+ """
+ i = named_class()
+ assert i.name == 'named_class'
+ assert i.cli == 'named-class'
+ assert i.doc == 'This class is so introspective!'
+
+
def test_Command():
class user(object):
name = 'user'