summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2009-01-13 19:49:23 -0700
committerJason Gerard DeRose <jderose@redhat.com>2009-01-13 19:49:23 -0700
commit659bb4c142ee9a987babd38fad93b539e51309f3 (patch)
tree81e15c0b061d18be1a1aa406f0b50d5bb5fbf079 /tests
parenta0fb215a2c5f2dfaf26b06f93c3a651f2420083d (diff)
downloadfreeipa-659bb4c142ee9a987babd38fad93b539e51309f3.tar.gz
freeipa-659bb4c142ee9a987babd38fad93b539e51309f3.tar.xz
freeipa-659bb4c142ee9a987babd38fad93b539e51309f3.zip
New Param: added Param.clone() method and corresponding unit test
Diffstat (limited to 'tests')
-rw-r--r--tests/test_ipalib/test_parameter.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/test_ipalib/test_parameter.py b/tests/test_ipalib/test_parameter.py
index 47cea89d6..8c4a93ab4 100644
--- a/tests/test_ipalib/test_parameter.py
+++ b/tests/test_ipalib/test_parameter.py
@@ -239,6 +239,41 @@ class test_Param(ClassChecker):
o = self.cls('name', multivalue=True)
assert repr(o) == "Param('name', multivalue=True)"
+ def test_clone(self):
+ """
+ Test the `ipalib.parameter.Param.clone` method.
+ """
+ # Test with the defaults
+ orig = self.cls('my_param')
+ clone = orig.clone()
+ assert clone is not orig
+ assert type(clone) is self.cls
+ assert clone.name is orig.name
+ for (key, kind, default) in self.cls.kwargs:
+ assert getattr(clone, key) is getattr(orig, key)
+
+ # Test with a param spec:
+ orig = self.cls('my_param*')
+ assert orig.param_spec == 'my_param*'
+ clone = orig.clone()
+ assert clone.param_spec == 'my_param'
+ assert clone is not orig
+ assert type(clone) is self.cls
+ for (key, kind, default) in self.cls.kwargs:
+ assert getattr(clone, key) is getattr(orig, key)
+
+ # Test with overrides:
+ orig = self.cls('my_param*')
+ assert orig.required is False
+ assert orig.multivalue is True
+ clone = orig.clone(required=True)
+ assert clone is not orig
+ assert type(clone) is self.cls
+ assert clone.required is True
+ assert clone.multivalue is True
+ assert clone.param_spec == 'my_param'
+ assert clone.name == 'my_param'
+
def test_get_label(self):
"""
Test the `ipalib.parameter.get_label` method.