diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2008-08-07 03:38:49 +0000 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2008-08-07 03:38:49 +0000 |
commit | fadbae642053565be1d10bc5d6b40b151a97ff16 (patch) | |
tree | 1ae0cd72ef0b97ca5ffc6419545efd510256782b /ipalib/tests/test_public.py | |
parent | f904cb0422194dc55cf74366145b2cf20299b657 (diff) | |
download | freeipa.git-fadbae642053565be1d10bc5d6b40b151a97ff16.tar.gz freeipa.git-fadbae642053565be1d10bc5d6b40b151a97ff16.tar.xz freeipa.git-fadbae642053565be1d10bc5d6b40b151a97ff16.zip |
72: Started work on public.opt class; added corresponding unit tests
Diffstat (limited to 'ipalib/tests/test_public.py')
-rw-r--r-- | ipalib/tests/test_public.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/ipalib/tests/test_public.py b/ipalib/tests/test_public.py index 0985658e..faffd02e 100644 --- a/ipalib/tests/test_public.py +++ b/ipalib/tests/test_public.py @@ -25,6 +25,41 @@ from tstutil import raises, getitem, no_set, no_del, read_only from ipalib import public, plugable, errors +def test_opt(): + cls = public.opt + assert issubclass(cls, plugable.ReadOnly) + + class int_opt(cls): + type = int + + i = int_opt() + + # Test with values that can't be converted: + nope = ( + '7.0' + 'whatever', + object, + None, + ) + for val in nope: + e = raises(errors.NormalizationError, i.normalize, val) + assert isinstance(e, errors.ValidationError) + assert e.name == 'int_opt' + assert e.value == val + assert e.error == "not <type 'int'>" + assert e.type is int + # Test with values that can be converted: + okay = ( + 7, + 7.0, + 7.2, + 7L, + '7', + ' 7 ', + ) + for val in okay: + assert i.normalize(val) == 7 + def test_cmd(): cls = public.cmd assert issubclass(cls, plugable.Plugin) @@ -35,6 +70,7 @@ def test_obj(): assert issubclass(cls, plugable.Plugin) + def test_attr(): cls = public.attr assert issubclass(cls, plugable.Plugin) |