From a6ec94da601273719e44c69c4d7c23776ab30f3a Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Thu, 28 Aug 2008 18:31:06 +0000 Subject: 217: Started work on new Option2 class that is more declarative and doesn't require subclassing from Option --- ipalib/tests/test_public.py | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'ipalib/tests/test_public.py') diff --git a/ipalib/tests/test_public.py b/ipalib/tests/test_public.py index 3ed1f5da..5b5d1d4b 100644 --- a/ipalib/tests/test_public.py +++ b/ipalib/tests/test_public.py @@ -22,7 +22,7 @@ Unit tests for `ipalib.public` module. """ from tstutil import raises, getitem, no_set, no_del, read_only, ClassChecker -from ipalib import public, plugable, errors +from ipalib import public, plugable, errors, ipa_types def test_RULE_FLAG(): @@ -104,6 +104,33 @@ class test_DefaltFrom(ClassChecker): assert o(**kw_copy) is None +class test_Option2(ClassChecker): + """ + Tests the `public.Option2` class. + """ + _cls = public.Option2 + + def test_class(self): + assert self.cls.__bases__ == (plugable.ReadOnly,) + + def test_init(self): + name = 'sn', + doc = 'Last Name', + type_ = ipa_types.Unicode() + o = self.cls(name, doc, type_) + assert o.__islocked__() is True + assert read_only(o, 'name') is name + assert read_only(o, 'doc') is doc + assert read_only(o, 'type') is type_ + assert read_only(o, 'required') is False + assert read_only(o, 'multivalue') is False + assert read_only(o, 'default') is None + assert read_only(o, 'default_from') is None + assert read_only(o, 'rules') == (type_.validate,) + + + + class test_Option(ClassChecker): """ Tests the `public.Option` class. -- cgit