diff options
-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 6cf9b5d7..c95397aa 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 3f993223..1c36d7bd 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): |