mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
190: Renamed public.option class to public.Option
This commit is contained in:
@@ -60,9 +60,9 @@ class DefaultFrom(plugable.ReadOnly):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
class option(plugable.Plugin):
|
class Option(plugable.Plugin):
|
||||||
"""
|
"""
|
||||||
The option class represents a kw argument from a command.
|
The Option class represents a kw argument from a `Command`.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__public__ = frozenset((
|
__public__ = frozenset((
|
||||||
@@ -118,7 +118,7 @@ class option(plugable.Plugin):
|
|||||||
self.__rules_iter(),
|
self.__rules_iter(),
|
||||||
key=lambda f: getattr(f, '__name__'),
|
key=lambda f: getattr(f, '__name__'),
|
||||||
))
|
))
|
||||||
object.__setattr__(self, '_option__rules', rules)
|
object.__setattr__(self, '_Option__rules', rules)
|
||||||
return self.__rules
|
return self.__rules
|
||||||
rules = property(__get_rules)
|
rules = property(__get_rules)
|
||||||
|
|
||||||
@@ -138,11 +138,11 @@ class option(plugable.Plugin):
|
|||||||
|
|
||||||
def default(self, **kw):
|
def default(self, **kw):
|
||||||
"""
|
"""
|
||||||
Returns a default or auto-completed value for this option. If no
|
Returns a default or auto-completed value for this Option. If no
|
||||||
default is available, this method should return None.
|
default is available, this method should return None.
|
||||||
|
|
||||||
All the keywords are passed so it's possible to build an
|
All the keywords are passed so it's possible to build an
|
||||||
auto-completed value from other options values, e.g., build 'initials'
|
auto-completed value from other Options values, e.g., build 'initials'
|
||||||
from 'givenname' + 'sn'.
|
from 'givenname' + 'sn'.
|
||||||
"""
|
"""
|
||||||
return None
|
return None
|
||||||
@@ -181,7 +181,7 @@ class Command(plugable.Plugin):
|
|||||||
assert inspect.isclass(cls)
|
assert inspect.isclass(cls)
|
||||||
o = cls()
|
o = cls()
|
||||||
o.__lock__()
|
o.__lock__()
|
||||||
yield plugable.PluginProxy(option, o)
|
yield plugable.PluginProxy(Option, o)
|
||||||
|
|
||||||
def __get_options(self):
|
def __get_options(self):
|
||||||
"""
|
"""
|
||||||
@@ -329,8 +329,8 @@ class Method(Attribute, Command):
|
|||||||
yield proxy
|
yield proxy
|
||||||
|
|
||||||
|
|
||||||
class Property(Attribute, option):
|
class Property(Attribute, Option):
|
||||||
__public__ = Attribute.__public__.union(option.__public__)
|
__public__ = Attribute.__public__.union(Option.__public__)
|
||||||
|
|
||||||
def get_doc(self, _):
|
def get_doc(self, _):
|
||||||
return _('Property doc')
|
return _('Property doc')
|
||||||
|
|||||||
@@ -98,11 +98,11 @@ class test_DefaltFrom(ClassChecker):
|
|||||||
assert o(**kw_copy) is None
|
assert o(**kw_copy) is None
|
||||||
|
|
||||||
|
|
||||||
class test_option(ClassChecker):
|
class test_Option(ClassChecker):
|
||||||
"""
|
"""
|
||||||
Tests the `public.option` class.
|
Tests the `public.Option` class.
|
||||||
"""
|
"""
|
||||||
_cls = public.option
|
_cls = public.Option
|
||||||
|
|
||||||
def get_subcls(self):
|
def get_subcls(self):
|
||||||
rule = public.rule
|
rule = public.rule
|
||||||
@@ -131,7 +131,7 @@ class test_option(ClassChecker):
|
|||||||
|
|
||||||
def test_normalize(self):
|
def test_normalize(self):
|
||||||
"""
|
"""
|
||||||
Tests the `public.option.normalize` method.
|
Tests the `public.Option.normalize` method.
|
||||||
"""
|
"""
|
||||||
assert 'normalize' in self.cls.__public__
|
assert 'normalize' in self.cls.__public__
|
||||||
o = self.subcls()
|
o = self.subcls()
|
||||||
@@ -163,7 +163,7 @@ class test_option(ClassChecker):
|
|||||||
|
|
||||||
def test_validate(self):
|
def test_validate(self):
|
||||||
"""
|
"""
|
||||||
Tests the `public.option.validate` method.
|
Tests the `public.Option.validate` method.
|
||||||
"""
|
"""
|
||||||
assert 'validate' in self.cls.__public__
|
assert 'validate' in self.cls.__public__
|
||||||
o = self.subcls()
|
o = self.subcls()
|
||||||
@@ -175,7 +175,7 @@ class test_option(ClassChecker):
|
|||||||
|
|
||||||
def test_rules(self):
|
def test_rules(self):
|
||||||
"""
|
"""
|
||||||
Tests the `public.option.rules` property.
|
Tests the `public.Option.rules` property.
|
||||||
"""
|
"""
|
||||||
o = self.subcls()
|
o = self.subcls()
|
||||||
assert len(o.rules) == 3
|
assert len(o.rules) == 3
|
||||||
@@ -186,20 +186,20 @@ class test_option(ClassChecker):
|
|||||||
|
|
||||||
def test_default(self):
|
def test_default(self):
|
||||||
"""
|
"""
|
||||||
Tests the `public.option.default` method.
|
Tests the `public.Option.default` method.
|
||||||
"""
|
"""
|
||||||
assert 'default' in self.cls.__public__
|
assert 'default' in self.cls.__public__
|
||||||
assert self.cls().default() is None
|
assert self.cls().default() is None
|
||||||
|
|
||||||
|
|
||||||
class test_cmd(ClassChecker):
|
class test_Command(ClassChecker):
|
||||||
"""
|
"""
|
||||||
Tests the `public.Command` class.
|
Tests the `public.Command` class.
|
||||||
"""
|
"""
|
||||||
_cls = public.Command
|
_cls = public.Command
|
||||||
|
|
||||||
def get_subcls(self):
|
def get_subcls(self):
|
||||||
class my_option(public.option):
|
class my_option(public.Option):
|
||||||
def normalize(self, value):
|
def normalize(self, value):
|
||||||
return super(my_option, self).normalize(value).lower()
|
return super(my_option, self).normalize(value).lower()
|
||||||
@public.rule
|
@public.rule
|
||||||
@@ -230,7 +230,7 @@ class test_cmd(ClassChecker):
|
|||||||
for (i, proxy) in enumerate(sub.get_options()):
|
for (i, proxy) in enumerate(sub.get_options()):
|
||||||
assert isinstance(proxy, plugable.PluginProxy)
|
assert isinstance(proxy, plugable.PluginProxy)
|
||||||
assert read_only(proxy, 'name') == 'option%d' % i
|
assert read_only(proxy, 'name') == 'option%d' % i
|
||||||
assert proxy.implements(public.option)
|
assert proxy.implements(public.Option)
|
||||||
assert i == 1
|
assert i == 1
|
||||||
|
|
||||||
def test_options(self):
|
def test_options(self):
|
||||||
@@ -448,9 +448,9 @@ class test_Method(ClassChecker):
|
|||||||
assert self.cls.implements(public.Command)
|
assert self.cls.implements(public.Command)
|
||||||
|
|
||||||
def get_subcls(self):
|
def get_subcls(self):
|
||||||
class option0(public.option):
|
class option0(public.Option):
|
||||||
pass
|
pass
|
||||||
class option1(public.option):
|
class option1(public.Option):
|
||||||
pass
|
pass
|
||||||
class example_prop0(public.Property):
|
class example_prop0(public.Property):
|
||||||
pass
|
pass
|
||||||
@@ -486,15 +486,15 @@ class test_Method(ClassChecker):
|
|||||||
for (i, proxy) in enumerate(proxies):
|
for (i, proxy) in enumerate(proxies):
|
||||||
assert proxy.name == names[i]
|
assert proxy.name == names[i]
|
||||||
assert isinstance(proxy, plugable.PluginProxy)
|
assert isinstance(proxy, plugable.PluginProxy)
|
||||||
assert proxy.implements(public.option)
|
assert proxy.implements(public.Option)
|
||||||
|
|
||||||
|
|
||||||
class test_prop(ClassChecker):
|
class test_prop(ClassChecker):
|
||||||
_cls = public.Property
|
_cls = public.Property
|
||||||
|
|
||||||
def test_class(self):
|
def test_class(self):
|
||||||
assert self.cls.__bases__ == (public.Attribute, public.option)
|
assert self.cls.__bases__ == (public.Attribute, public.Option)
|
||||||
assert self.cls.implements(public.option)
|
assert self.cls.implements(public.Option)
|
||||||
|
|
||||||
|
|
||||||
def test_PublicAPI():
|
def test_PublicAPI():
|
||||||
|
|||||||
Reference in New Issue
Block a user