From e756e12718a538d82de45fbba3a5e97f3a4d7d7f Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Sat, 9 Aug 2008 19:09:10 +0000 Subject: 99: Cleaned up unit tests for plugable.Plugin --- ipalib/tests/test_plugable.py | 58 +++++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 24 deletions(-) (limited to 'ipalib/tests/test_plugable.py') diff --git a/ipalib/tests/test_plugable.py b/ipalib/tests/test_plugable.py index 42453ed5..af52f4ee 100644 --- a/ipalib/tests/test_plugable.py +++ b/ipalib/tests/test_plugable.py @@ -296,30 +296,40 @@ class test_Proxy(ClassChecker): assert read_only(c, 'name') == 'another_name' -def test_Plugin(): - cls = plugable.Plugin - assert type(cls.name) is property - - api = 'the api instance' - p = plugable.Plugin() - assert read_only(p, 'name') == 'Plugin' - assert repr(p) == '%s.Plugin()' % plugable.__name__ - assert read_only(p, 'api') is None - raises(AssertionError, p.finalize, None) - p.finalize(api) - assert read_only(p, 'api') is api - raises(AssertionError, p.finalize, api) - - class some_plugin(plugable.Plugin): - pass - p = some_plugin() - assert read_only(p, 'name') == 'some_plugin' - assert repr(p) == '%s.some_plugin()' % __name__ - assert read_only(p, 'api') is None - raises(AssertionError, p.finalize, None) - p.finalize(api) - assert read_only(p, 'api') is api - raises(AssertionError, p.finalize, api) +class test_Plugin(ClassChecker): + """ + Tests the `Plugin` class. + """ + _cls = plugable.Plugin + + def test_class(self): + assert self.cls.__bases__ == (plugable.ProxyTarget,) + assert type(self.cls.api) is property + + def test_finalize(self): + """ + Tests the `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) def test_NameSpace(): -- cgit