diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2009-01-14 09:56:10 -0700 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2009-01-14 09:56:10 -0700 |
commit | 05514292dcf2448f0340e09cd0da88f815c43c5b (patch) | |
tree | 1b7d1956b544f5e128ad0671c57b9470639df240 /tests | |
parent | 8cc38e681f9caca838540511664337f964302f56 (diff) | |
download | freeipa-05514292dcf2448f0340e09cd0da88f815c43c5b.tar.gz freeipa-05514292dcf2448f0340e09cd0da88f815c43c5b.tar.xz freeipa-05514292dcf2448f0340e09cd0da88f815c43c5b.zip |
New Param: Flag now fill-in default=False and also forces default to be a bool
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_ipalib/test_parameter.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/tests/test_ipalib/test_parameter.py b/tests/test_ipalib/test_parameter.py index 4a6fee55e..d98888ab8 100644 --- a/tests/test_ipalib/test_parameter.py +++ b/tests/test_ipalib/test_parameter.py @@ -554,22 +554,38 @@ class test_Flag(ClassChecker): """ Test the `ipalib.parameter.Flag.__init__` method. """ + # Test with no kwargs: o = self.cls('my_flag') assert o.type is bool assert isinstance(o, parameter.Bool) assert o.autofill is True + assert o.default is False - # Test with autofill=False - o = self.cls('my_flag', autofill=False) + # Test that TypeError is raise if default is not a bool: + e = raises(TypeError, self.cls, 'my_flag', default=None) + assert str(e) == TYPE_ERROR % ('default', bool, None, NoneType) + + # Test with autofill=False, default=True + o = self.cls('my_flag', autofill=False, default=True) assert o.autofill is True + assert o.default is True # Test when cloning: orig = self.cls('my_flag') for clone in [orig.clone(), orig.clone(autofill=False)]: assert clone.autofill is True + assert clone.default is False assert clone is not orig assert type(clone) is self.cls + # Test when cloning with default=True/False + orig = self.cls('my_flag') + assert orig.clone().default is False + assert orig.clone(default=True).default is True + orig = self.cls('my_flag', default=True) + assert orig.clone().default is True + assert orig.clone(default=False).default is False + class test_Bytes(ClassChecker): """ |