diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2008-08-09 19:09:10 +0000 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2008-08-09 19:09:10 +0000 |
commit | e756e12718a538d82de45fbba3a5e97f3a4d7d7f (patch) | |
tree | 597520e183d8ee904b9cfc15d6dd4823d8ee5f4d /ipalib | |
parent | 5315514f6c773de897c2e74a4ad31bbfeeae2bda (diff) | |
download | freeipa-e756e12718a538d82de45fbba3a5e97f3a4d7d7f.tar.gz freeipa-e756e12718a538d82de45fbba3a5e97f3a4d7d7f.tar.xz freeipa-e756e12718a538d82de45fbba3a5e97f3a4d7d7f.zip |
99: Cleaned up unit tests for plugable.Plugin
Diffstat (limited to 'ipalib')
-rw-r--r-- | ipalib/plugable.py | 2 | ||||
-rw-r--r-- | ipalib/tests/test_plugable.py | 58 |
2 files changed, 35 insertions, 25 deletions
diff --git a/ipalib/plugable.py b/ipalib/plugable.py index 7a5719959..b4a6fb10d 100644 --- a/ipalib/plugable.py +++ b/ipalib/plugable.py @@ -268,7 +268,7 @@ class Plugin(ProxyTarget): def __repr__(self): """ Returns a fully qualified module_name.class_name() representation that - could be used to contruct this instance. + could be used to construct this Plugin instance. """ return '%s.%s()' % ( self.__class__.__module__, diff --git a/ipalib/tests/test_plugable.py b/ipalib/tests/test_plugable.py index 42453ed5c..af52f4ee0 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(): |