summaryrefslogtreecommitdiffstats
path: root/ipalib/tests/test_plugable.py
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2008-08-06 21:54:56 +0000
committerJason Gerard DeRose <jderose@redhat.com>2008-08-06 21:54:56 +0000
commitf13f1226b4b798fd901ece6b9a37c06ca25c3c2e (patch)
tree3f3f10033a937f0817bf3f7f9370975290991872 /ipalib/tests/test_plugable.py
parent0c7769473ca01facdcb1768868bfd053e726fddf (diff)
downloadfreeipa.git-f13f1226b4b798fd901ece6b9a37c06ca25c3c2e.tar.gz
freeipa.git-f13f1226b4b798fd901ece6b9a37c06ca25c3c2e.tar.xz
freeipa.git-f13f1226b4b798fd901ece6b9a37c06ca25c3c2e.zip
65: Finished simplified Proxy2 class; updated unit tests
Diffstat (limited to 'ipalib/tests/test_plugable.py')
-rw-r--r--ipalib/tests/test_plugable.py31
1 files changed, 15 insertions, 16 deletions
diff --git a/ipalib/tests/test_plugable.py b/ipalib/tests/test_plugable.py
index 40e98ed3..383e068e 100644
--- a/ipalib/tests/test_plugable.py
+++ b/ipalib/tests/test_plugable.py
@@ -170,23 +170,22 @@ def test_Proxy():
def test_Proxy2():
cls = plugable.Proxy2
- export = plugable.export
assert issubclass(cls, plugable.ReadOnly)
# Setup:
class base(object):
- @export
+ public = frozenset((
+ 'public_0',
+ 'public_1',
+ '__call__',
+ ))
+
def public_0(self):
return 'public_0'
- @export
def public_1(self):
return 'public_1'
- @export
- def _get_some_prop(self):
- return 'ya got it'
-
def __call__(self, caller):
return 'ya called it, %s.' % caller
@@ -197,7 +196,8 @@ def test_Proxy2():
return 'private_1'
class plugin(base):
- pass
+ name = 'user_add'
+ attr_name = 'add'
# Test that TypeError is raised when base is not a class:
raises(TypeError, cls, base(), None)
@@ -209,7 +209,8 @@ def test_Proxy2():
i = plugin()
p = cls(base, i)
assert read_only(p, 'base') is base
- assert list(p) == ['_get_some_prop', 'public_0', 'public_1']
+ assert read_only(p, 'name') is 'user_add'
+ assert list(p) == sorted(base.public)
# Test normal methods:
for n in xrange(2):
@@ -217,6 +218,7 @@ def test_Proxy2():
priv = 'private_%d' % n
assert getattr(i, pub)() == pub
assert getattr(p, pub)() == pub
+ assert hasattr(p, pub)
assert getattr(i, priv)() == priv
assert not hasattr(p, priv)
@@ -224,14 +226,11 @@ def test_Proxy2():
value = 'ya called it, dude.'
assert i('dude') == value
assert p('dude') == value
+ assert callable(p)
- # Test implied property:
- fget = '_get_some_prop'
- name = 'some_prop'
- value = 'ya got it'
- assert getattr(i, fget)() == value
- assert getattr(p, fget)() == value
- assert getattr(p, name) == value
+ # Test name_attr='name' kw arg
+ i = plugin()
+ p = cls(base, i)