summaryrefslogtreecommitdiffstats
path: root/ipalib/tests
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2008-08-28 02:45:04 +0000
committerJason Gerard DeRose <jderose@redhat.com>2008-08-28 02:45:04 +0000
commitd121a729aa1b0e97dcf927bfc66eb86a73529863 (patch)
tree7a6cb64f1f593fbc353e5217185f7cc85e2ba921 /ipalib/tests
parent81d0726f5e1cf30a7ea3b8c3da8cf96780044164 (diff)
downloadfreeipa.git-d121a729aa1b0e97dcf927bfc66eb86a73529863.tar.gz
freeipa.git-d121a729aa1b0e97dcf927bfc66eb86a73529863.tar.xz
freeipa.git-d121a729aa1b0e97dcf927bfc66eb86a73529863.zip
212: Type.__init__() now can also raise TypeError; added unit tests for Type.__init__()
Diffstat (limited to 'ipalib/tests')
-rw-r--r--ipalib/tests/test_ipa_types.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/ipalib/tests/test_ipa_types.py b/ipalib/tests/test_ipa_types.py
index 4ca44121..f594aabf 100644
--- a/ipalib/tests/test_ipa_types.py
+++ b/ipalib/tests/test_ipa_types.py
@@ -69,6 +69,24 @@ class test_Type(ClassChecker):
def test_class(self):
assert self.cls.__bases__ == (plugable.ReadOnly,)
+ def test_init(self):
+ okay = (bool, int, float, unicode)
+ for t in okay:
+ o = self.cls(t)
+ assert o.__islocked__() is True
+ assert read_only(o, 'type') is t
+ assert read_only(o, 'name') is 'Type'
+
+ type_errors = (None, True, 8, 8.0, u'hello')
+ for t in type_errors:
+ e = raises(TypeError, self.cls, t)
+ assert str(e) == '%r is not %r' % (type(t), type)
+
+ value_errors = (long, complex, str, tuple, list, dict, set, frozenset)
+ for t in value_errors:
+ e = raises(ValueError, self.cls, t)
+ assert str(e) == 'not an allowed type: %r' % t
+
class test_Int(ClassChecker):
_cls = ipa_types.Int