mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-25 08:21:05 -06:00
Added new Param.flags attribute (set with flags=foo kwarg)
This commit is contained in:
parent
f7b7fa5553
commit
8322138f38
@ -207,6 +207,7 @@ class Param(plugable.ReadOnly):
|
||||
normalize callable None
|
||||
default same as type.type None
|
||||
default_from callable None
|
||||
flags frozenset frozenset()
|
||||
============ ================= ==================
|
||||
"""
|
||||
__nones = (None, '', tuple(), [])
|
||||
@ -220,6 +221,7 @@ class Param(plugable.ReadOnly):
|
||||
normalize=None,
|
||||
default=None,
|
||||
default_from=None,
|
||||
flags=frozenset(),
|
||||
rules=tuple(),
|
||||
)
|
||||
|
||||
@ -249,6 +251,7 @@ class Param(plugable.ReadOnly):
|
||||
self.default_from = check_type(df, DefaultFrom, 'default_from',
|
||||
allow_none=True
|
||||
)
|
||||
self.flags = frozenset(kw['flags'])
|
||||
self.__normalize = kw['normalize']
|
||||
self.rules = self.__check_type(tuple, 'rules')
|
||||
self.all_rules = (self.type.validate,) + self.rules
|
||||
|
@ -162,6 +162,7 @@ class test_Param(ClassChecker):
|
||||
assert read_only(o, 'multivalue') is False
|
||||
assert read_only(o, 'default') is None
|
||||
assert read_only(o, 'default_from') is None
|
||||
assert read_only(o, 'flags') == frozenset()
|
||||
assert read_only(o, 'rules') == tuple()
|
||||
assert len(read_only(o, 'all_rules')) == 1
|
||||
assert read_only(o, 'primary_key') is False
|
||||
@ -183,6 +184,8 @@ class test_Param(ClassChecker):
|
||||
assert type(o.default_from) is frontend.DefaultFrom
|
||||
assert o.default_from.keys == ('first', 'last')
|
||||
assert o.default_from.callback('butt', 'erfly') == 'butterfly'
|
||||
assert self.cls(name, flags=('one', 'two', 'three')).flags == \
|
||||
frozenset(['one', 'two', 'three'])
|
||||
rules = (lambda whatever: 'Not okay!',)
|
||||
o = self.cls(name, rules=rules)
|
||||
assert o.rules is rules
|
||||
|
Loading…
Reference in New Issue
Block a user