diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2008-09-25 03:27:40 +0000 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2008-09-25 03:27:40 +0000 |
commit | 152f3089e15eec0ce9f7af07450785114a3fcb6e (patch) | |
tree | 3874cba5091b3cf1a4f078bb61decbc92ae4921b | |
parent | c303a06a948d1813336161e2546bd85f8edead56 (diff) | |
download | freeipa-152f3089e15eec0ce9f7af07450785114a3fcb6e.tar.gz freeipa-152f3089e15eec0ce9f7af07450785114a3fcb6e.tar.xz freeipa-152f3089e15eec0ce9f7af07450785114a3fcb6e.zip |
363: Added Object.params_minus_pk instance attribute
-rw-r--r-- | ipalib/frontend.py | 5 | ||||
-rw-r--r-- | ipalib/tests/test_frontend.py | 5 |
2 files changed, 10 insertions, 0 deletions
diff --git a/ipalib/frontend.py b/ipalib/frontend.py index 6cf9b5d7b..c95397aa3 100644 --- a/ipalib/frontend.py +++ b/ipalib/frontend.py @@ -515,11 +515,13 @@ class Object(plugable.Plugin): 'properties', 'params', 'primary_key', + 'params_minus_pk', )) methods = None properties = None params = None primary_key = None + params_minus_pk = None takes_params = tuple() def set_api(self, api): @@ -543,6 +545,9 @@ class Object(plugable.Plugin): ) if len(pkeys) == 1: self.primary_key = pkeys[0] + self.params_minus_pk = plugable.NameSpace( + filter(lambda p: not p.primary_key, self.params()), sort=False + ) def __get_attrs(self, name): namespace = getattr(self.api, name) diff --git a/ipalib/tests/test_frontend.py b/ipalib/tests/test_frontend.py index 3f9932234..1c36d7bdd 100644 --- a/ipalib/tests/test_frontend.py +++ b/ipalib/tests/test_frontend.py @@ -763,6 +763,7 @@ class test_Object(ClassChecker): assert self.cls.methods is None assert self.cls.properties is None assert self.cls.params is None + assert self.cls.params_minus_pk is None assert self.cls.takes_params == tuple() def test_init(self): @@ -773,6 +774,7 @@ class test_Object(ClassChecker): assert o.methods is None assert o.properties is None assert o.params is None + assert o.params_minus_pk is None assert o.properties is None def test_set_api(self): @@ -877,6 +879,7 @@ class test_Object(ClassChecker): o = example1() o.set_api(api) assert o.primary_key is None + assert o.params_minus_pk is None # Test with 1 primary key: class example2(self.cls): @@ -895,6 +898,8 @@ class test_Object(ClassChecker): assert pk.name == 'three' assert pk.primary_key is True assert o.params[2] is o.primary_key + assert isinstance(o.params_minus_pk, plugable.NameSpace) + assert list(o.params_minus_pk) == ['one', 'two', 'four'] # Test with multiple primary_key: class example3(self.cls): |