diff options
author | Jan Cholasta <jcholast@redhat.com> | 2015-06-15 12:06:47 +0000 |
---|---|---|
committer | Jan Cholasta <jcholast@redhat.com> | 2015-07-01 13:05:30 +0000 |
commit | 1a21fd971ccc26cf8f06d1ba965b263856be56c6 (patch) | |
tree | e38be05a67287438ff824053c117e0d3be3ed1a1 /ipatests | |
parent | e9c9e3f009347d356f4d59701321888e7f00fb94 (diff) | |
download | freeipa-1a21fd971ccc26cf8f06d1ba965b263856be56c6.tar.gz freeipa-1a21fd971ccc26cf8f06d1ba965b263856be56c6.tar.xz freeipa-1a21fd971ccc26cf8f06d1ba965b263856be56c6.zip |
plugable: Remove SetProxy, DictProxy and MagicDict
https://fedorahosted.org/freeipa/ticket/3090
Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
Diffstat (limited to 'ipatests')
-rw-r--r-- | ipatests/test_ipalib/test_plugable.py | 170 |
1 files changed, 0 insertions, 170 deletions
diff --git a/ipatests/test_ipalib/test_plugable.py b/ipatests/test_ipalib/test_plugable.py index 0d2763def..f5434e8a4 100644 --- a/ipatests/test_ipalib/test_plugable.py +++ b/ipatests/test_ipalib/test_plugable.py @@ -32,176 +32,6 @@ from ipalib import plugable, errors, text from ipaplatform.paths import paths -class test_SetProxy(ClassChecker): - """ - Test the `ipalib.plugable.SetProxy` class. - """ - _cls = plugable.SetProxy - - def test_class(self): - """ - Test the `ipalib.plugable.SetProxy` class. - """ - assert self.cls.__bases__ == (plugable.ReadOnly,) - - def test_init(self): - """ - Test the `ipalib.plugable.SetProxy.__init__` method. - """ - okay = (set, frozenset, dict) - fail = (list, tuple) - for t in okay: - self.cls(t()) - raises(TypeError, self.cls, t) - for t in fail: - raises(TypeError, self.cls, t()) - raises(TypeError, self.cls, t) - - def test_SetProxy(self): - """ - Test container emulation of `ipalib.plugable.SetProxy` class. - """ - def get_key(i): - return 'key_%d' % i - - cnt = 10 - target = set() - proxy = self.cls(target) - for i in xrange(cnt): - key = get_key(i) - - # Check initial state - assert len(proxy) == len(target) - assert list(proxy) == sorted(target) - assert key not in proxy - assert key not in target - - # Add and test again - target.add(key) - assert len(proxy) == len(target) - assert list(proxy) == sorted(target) - assert key in proxy - assert key in target - - -class test_DictProxy(ClassChecker): - """ - Test the `ipalib.plugable.DictProxy` class. - """ - _cls = plugable.DictProxy - - def test_class(self): - """ - Test the `ipalib.plugable.DictProxy` class. - """ - assert self.cls.__bases__ == (plugable.SetProxy,) - - def test_init(self): - """ - Test the `ipalib.plugable.DictProxy.__init__` method. - """ - self.cls(dict()) - raises(TypeError, self.cls, dict) - fail = (set, frozenset, list, tuple) - for t in fail: - raises(TypeError, self.cls, t()) - raises(TypeError, self.cls, t) - - def test_DictProxy(self): - """ - Test container emulation of `ipalib.plugable.DictProxy` class. - """ - def get_kv(i): - return ( - 'key_%d' % i, - 'val_%d' % i, - ) - cnt = 10 - target = dict() - proxy = self.cls(target) - for i in xrange(cnt): - (key, val) = get_kv(i) - - # Check initial state - assert len(proxy) == len(target) - assert list(proxy) == sorted(target) - assert list(proxy()) == [target[k] for k in sorted(target)] - assert key not in proxy - raises(KeyError, getitem, proxy, key) - - # Add and test again - target[key] = val - assert len(proxy) == len(target) - assert list(proxy) == sorted(target) - assert list(proxy()) == [target[k] for k in sorted(target)] - - # Verify TypeError is raised trying to set/del via proxy - raises(TypeError, setitem, proxy, key, val) - raises(TypeError, delitem, proxy, key) - - -class test_MagicDict(ClassChecker): - """ - Test the `ipalib.plugable.MagicDict` class. - """ - _cls = plugable.MagicDict - - def test_class(self): - """ - Test the `ipalib.plugable.MagicDict` class. - """ - assert self.cls.__bases__ == (plugable.DictProxy,) - for non_dict in ('hello', 69, object): - raises(TypeError, self.cls, non_dict) - - def test_MagicDict(self): - """ - Test container emulation of `ipalib.plugable.MagicDict` class. - """ - cnt = 10 - keys = [] - d = dict() - dictproxy = self.cls(d) - for i in xrange(cnt): - key = 'key_%d' % i - val = 'val_%d' % i - keys.append(key) - - # Test thet key does not yet exist - assert len(dictproxy) == i - assert key not in dictproxy - assert not hasattr(dictproxy, key) - raises(KeyError, getitem, dictproxy, key) - raises(AttributeError, getattr, dictproxy, key) - - # Test that items/attributes cannot be set on dictproxy: - raises(TypeError, setitem, dictproxy, key, val) - raises(AttributeError, setattr, dictproxy, key, val) - - # Test that additions in d are reflected in dictproxy: - d[key] = val - assert len(dictproxy) == i + 1 - assert key in dictproxy - assert hasattr(dictproxy, key) - assert dictproxy[key] is val - assert read_only(dictproxy, key) is val - - # Test __iter__ - assert list(dictproxy) == keys - - for key in keys: - # Test that items cannot be deleted through dictproxy: - raises(TypeError, delitem, dictproxy, key) - raises(AttributeError, delattr, dictproxy, key) - - # Test that deletions in d are reflected in dictproxy - del d[key] - assert len(dictproxy) == len(d) - assert key not in dictproxy - raises(KeyError, getitem, dictproxy, key) - raises(AttributeError, getattr, dictproxy, key) - - class test_Plugin(ClassChecker): """ Test the `ipalib.plugable.Plugin` class. |