diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2008-09-21 21:50:56 +0000 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2008-09-21 21:50:56 +0000 |
commit | f73d976bdacae37557f0b2ccfa6da01ea58c685d (patch) | |
tree | 78f98c60cc3f268b3354ae6fda69d296ff330ae1 /ipalib/tests | |
parent | 5872221bd49dda962391ddfb88f22e86bf72afec (diff) | |
download | freeipa.git-f73d976bdacae37557f0b2ccfa6da01ea58c685d.tar.gz freeipa.git-f73d976bdacae37557f0b2ccfa6da01ea58c685d.tar.xz freeipa.git-f73d976bdacae37557f0b2ccfa6da01ea58c685d.zip |
307: Split Plugin.finalize() into two steps 1) Plugin.set_api() and 2) Plugin.finalize(); updated unit tests
Diffstat (limited to 'ipalib/tests')
-rw-r--r-- | ipalib/tests/test_plugable.py | 22 | ||||
-rw-r--r-- | ipalib/tests/test_public.py | 26 |
2 files changed, 16 insertions, 32 deletions
diff --git a/ipalib/tests/test_plugable.py b/ipalib/tests/test_plugable.py index 3972cfa9..6c796f9e 100644 --- a/ipalib/tests/test_plugable.py +++ b/ipalib/tests/test_plugable.py @@ -405,26 +405,10 @@ class test_Plugin(ClassChecker): """ Tests the `plugable.Plugin.finalize` method. """ - api = 'the api instance' o = self.cls() - assert read_only(o, 'name') == 'Plugin' - assert repr(o) == '%s.Plugin()' % plugable.__name__ - assert read_only(o, 'api') is None - raises(AssertionError, o.finalize, None) - o.finalize(api) - assert read_only(o, 'api') is api - raises(AssertionError, o.finalize, api) - - class some_plugin(self.cls): - pass - sub = some_plugin() - assert read_only(sub, 'name') == 'some_plugin' - assert repr(sub) == '%s.some_plugin()' % __name__ - assert read_only(sub, 'api') is None - raises(AssertionError, sub.finalize, None) - sub.finalize(api) - assert read_only(sub, 'api') is api - raises(AssertionError, sub.finalize, api) + assert not o.__islocked__() + o.finalize() + assert o.__islocked__() class test_PluginProxy(ClassChecker): diff --git a/ipalib/tests/test_public.py b/ipalib/tests/test_public.py index 865a18fd..d963233b 100644 --- a/ipalib/tests/test_public.py +++ b/ipalib/tests/test_public.py @@ -379,7 +379,7 @@ class test_Command(ClassChecker): takes_args = args takes_options = options o = example() - o.finalize(object) + o.finalize() return o def test_class(self): @@ -412,7 +412,7 @@ class test_Command(ClassChecker): assert 'args' in self.cls.__public__ # Public assert self.cls().args is None o = self.cls() - o.finalize(object) + o.finalize() assert type(o.args) is plugable.NameSpace assert len(o.args) == 0 args = ('destination', 'source?') @@ -462,7 +462,7 @@ class test_Command(ClassChecker): assert 'options' in self.cls.__public__ # Public assert self.cls().options is None o = self.cls() - o.finalize(object) + o.finalize() assert type(o.options) is plugable.NameSpace assert len(o.options) == 0 options = ('target', 'files*') @@ -491,7 +491,7 @@ class test_Command(ClassChecker): expected = dict(kw) expected.update(dict(option0=u'option0', option1=u'option1')) o = self.subcls() - o.finalize(object) + o.finalize() for (key, value) in o.convert(**kw).iteritems(): v = expected[key] assert value == v @@ -509,7 +509,7 @@ class test_Command(ClassChecker): ) norm = dict((k, v.lower()) for (k, v) in kw.items()) sub = self.subcls() - sub.finalize(object) + sub.finalize() assert sub.normalize(**kw) == norm def test_get_default(self): @@ -530,7 +530,7 @@ class test_Command(ClassChecker): option1='the default', ) sub = self.subcls() - sub.finalize(object) + sub.finalize() assert sub.get_default(**no_fill) == {} assert sub.get_default(**fill) == default @@ -541,7 +541,7 @@ class test_Command(ClassChecker): assert 'validate' in self.cls.__public__ # Public sub = self.subcls() - sub.finalize(object) + sub.finalize() # Check with valid args okay = dict( @@ -639,9 +639,9 @@ class test_Object(ClassChecker): assert read_only(o, 'Method') is None assert read_only(o, 'Property') is None - def test_finalize(self): + def test_set_api(self): """ - Tests the `public.Object.finalize` method. + Tests the `public.Object.set_api` method. """ # Setup for test: class DummyAttribute(object): @@ -685,7 +685,7 @@ class test_Object(ClassChecker): # Actually perform test: o = user() - o.finalize(api) + o.set_api(api) assert read_only(o, 'api') is api for name in ['Method', 'Property']: namespace = getattr(o, name) @@ -725,9 +725,9 @@ class test_Attribute(ClassChecker): assert read_only(o, 'obj_name') == 'user' assert read_only(o, 'attr_name') == 'add' - def test_finalize(self): + def test_set_api(self): """ - Tests the `public.Attribute.finalize` method. + Tests the `public.Attribute.set_api` method. """ user_obj = 'The user public.Object instance' class api(object): @@ -737,7 +737,7 @@ class test_Attribute(ClassChecker): o = user_add() assert read_only(o, 'api') is None assert read_only(o, 'obj') is None - o.finalize(api) + o.set_api(api) assert read_only(o, 'api') is api assert read_only(o, 'obj') is user_obj |