From b0976a520858ccc1120c2cf5aabfc5e03a065ced Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Fri, 8 Aug 2008 20:39:34 +0000 Subject: 83: Added unit tests for plugable.Abstract --- ipalib/tests/test_plugable.py | 50 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'ipalib/tests/test_plugable.py') diff --git a/ipalib/tests/test_plugable.py b/ipalib/tests/test_plugable.py index 232fbd71..ad1645f1 100644 --- a/ipalib/tests/test_plugable.py +++ b/ipalib/tests/test_plugable.py @@ -61,6 +61,56 @@ def test_valid_identifier(): raises(errors.NameSpaceError, f, name.upper()) +def test_Abstract(): + cls = plugable.Abstract + + class example(cls): + __public__ = frozenset(( + 'some_method', + 'some_property', + )) + + # Test using str: + assert example.implements('some_method') + assert not example.implements('another_method') + + # Test using frozenset: + assert example.implements(frozenset(['some_method'])) + assert not example.implements( + frozenset(['some_method', 'another_method']) + ) + + # Test using another object/class with __public__ frozenset: + assert example.implements(example) + assert example().implements(example) + assert example.implements(example()) + assert example().implements(example()) + + class subset(cls): + __public__ = frozenset(( + 'some_property', + )) + assert example.implements(subset) + assert not subset.implements(example) + + class superset(cls): + __public__ = frozenset(( + 'some_method', + 'some_property', + 'another_property', + )) + assert not example.implements(superset) + assert superset.implements(example) + + class any_object(object): + __public__ = frozenset(( + 'some_method', + 'some_property', + )) + assert example.implements(any_object) + assert example.implements(any_object()) + + def test_Plugin(): cls = plugable.Plugin assert type(cls.name) is property -- cgit