mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-01-11 08:41:55 -06:00
100: Cleaned up NameSpace docstrings; cleanup up NameSpace unit tests
This commit is contained in:
parent
e756e12718
commit
0e532cd7b3
@ -278,13 +278,17 @@ class Plugin(ProxyTarget):
|
|||||||
|
|
||||||
class NameSpace(ReadOnly):
|
class NameSpace(ReadOnly):
|
||||||
"""
|
"""
|
||||||
A read-only namespace of (key, value) pairs that can be accessed
|
A read-only namespace of Proxy instances. Proxy.name is used to name the
|
||||||
both as instance attributes and as dictionary items.
|
attributes pointing to the Proxy instances, which can also be accesses
|
||||||
|
through a dictionary interface, for example:
|
||||||
|
|
||||||
|
>>> assert namespace.my_proxy is namespace['my_proxy'] # True
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, proxies):
|
def __init__(self, proxies):
|
||||||
"""
|
"""
|
||||||
NameSpace
|
`proxies` - an iterable returning the Proxy instances to be contained
|
||||||
|
in this NameSpace.
|
||||||
"""
|
"""
|
||||||
self.__proxies = tuple(proxies)
|
self.__proxies = tuple(proxies)
|
||||||
self.__d = dict()
|
self.__d = dict()
|
||||||
@ -299,7 +303,7 @@ class NameSpace(ReadOnly):
|
|||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
"""
|
"""
|
||||||
Iterates through the proxies in this NameSpace in the same order they
|
Iterates through the proxies in this NameSpace in the same order they
|
||||||
were passed in the contructor.
|
were passed to the constructor.
|
||||||
"""
|
"""
|
||||||
for proxy in self.__proxies:
|
for proxy in self.__proxies:
|
||||||
yield proxy
|
yield proxy
|
||||||
|
@ -332,10 +332,16 @@ class test_Plugin(ClassChecker):
|
|||||||
raises(AssertionError, sub.finalize, api)
|
raises(AssertionError, sub.finalize, api)
|
||||||
|
|
||||||
|
|
||||||
def test_NameSpace():
|
class test_NameSpace(ClassChecker):
|
||||||
cls = plugable.NameSpace
|
"""
|
||||||
assert issubclass(cls, plugable.ReadOnly)
|
Tests the `NameSpace` class.
|
||||||
|
"""
|
||||||
|
_cls = plugable.NameSpace
|
||||||
|
|
||||||
|
def test_class(self):
|
||||||
|
assert self.cls.__bases__ == (plugable.ReadOnly,)
|
||||||
|
|
||||||
|
def test_namespace(self):
|
||||||
class base(object):
|
class base(object):
|
||||||
__public__ = frozenset((
|
__public__ = frozenset((
|
||||||
'plusplus',
|
'plusplus',
|
||||||
@ -356,7 +362,8 @@ def test_NameSpace():
|
|||||||
yield plugable.Proxy(base, plugin(get_name(i)))
|
yield plugable.Proxy(base, plugin(get_name(i)))
|
||||||
|
|
||||||
cnt = 20
|
cnt = 20
|
||||||
ns = cls(get_proxies(cnt))
|
ns = self.cls(get_proxies(cnt))
|
||||||
|
assert ns.__islocked__() is True
|
||||||
|
|
||||||
# Test __len__
|
# Test __len__
|
||||||
assert len(ns) == cnt
|
assert len(ns) == cnt
|
||||||
@ -380,7 +387,7 @@ def test_NameSpace():
|
|||||||
assert read_only(ns, name) is proxy
|
assert read_only(ns, name) is proxy
|
||||||
|
|
||||||
# Test dir():
|
# Test dir():
|
||||||
assert set(get_name(i) for i in xrange(cnt)).issubset(set(dir(ns)))
|
assert set(get_name(i) for i in xrange(cnt)).issubset(dir(ns))
|
||||||
|
|
||||||
# Test that KeyError, AttributeError is raised:
|
# Test that KeyError, AttributeError is raised:
|
||||||
name = get_name(cnt)
|
name = get_name(cnt)
|
||||||
|
Loading…
Reference in New Issue
Block a user