From f13f1226b4b798fd901ece6b9a37c06ca25c3c2e Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Wed, 6 Aug 2008 21:54:56 +0000 Subject: 65: Finished simplified Proxy2 class; updated unit tests --- ipalib/tests/test_plugable.py | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'ipalib/tests/test_plugable.py') 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) -- cgit