mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
All unit tests now working (except for doctests and Rob's xmlrpc tests)
This commit is contained in:
parent
09e2f5d615
commit
79422d0489
@ -56,7 +56,7 @@ class Mod(frontend.Method):
|
|||||||
|
|
||||||
def get_options(self):
|
def get_options(self):
|
||||||
for param in self.obj.params_minus_pk():
|
for param in self.obj.params_minus_pk():
|
||||||
yield param.__clone__(required=False)
|
yield param.clone(required=False)
|
||||||
for option in self.takes_options:
|
for option in self.takes_options:
|
||||||
yield option
|
yield option
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ class Find(frontend.Method):
|
|||||||
|
|
||||||
def get_options(self):
|
def get_options(self):
|
||||||
for param in self.obj.params_minus_pk():
|
for param in self.obj.params_minus_pk():
|
||||||
yield param.__clone__(required=False)
|
yield param.clone(required=False)
|
||||||
for option in self.takes_options:
|
for option in self.takes_options:
|
||||||
yield option
|
yield option
|
||||||
|
|
||||||
|
@ -521,7 +521,13 @@ class Param(ReadOnly):
|
|||||||
for rule in self.all_rules:
|
for rule in self.all_rules:
|
||||||
error = rule(ugettext, value)
|
error = rule(ugettext, value)
|
||||||
if error is not None:
|
if error is not None:
|
||||||
raise ValidationError(name=self.name, error=error, index=index)
|
raise ValidationError(
|
||||||
|
name=self.name,
|
||||||
|
value=value,
|
||||||
|
index=index,
|
||||||
|
error=error,
|
||||||
|
rule=rule,
|
||||||
|
)
|
||||||
|
|
||||||
def get_default(self, **kw):
|
def get_default(self, **kw):
|
||||||
"""
|
"""
|
||||||
|
@ -23,8 +23,9 @@ Test the `ipalib.frontend` module.
|
|||||||
|
|
||||||
from tests.util import raises, getitem, no_set, no_del, read_only
|
from tests.util import raises, getitem, no_set, no_del, read_only
|
||||||
from tests.util import check_TypeError, ClassChecker, create_test_api
|
from tests.util import check_TypeError, ClassChecker, create_test_api
|
||||||
|
from tests.util import assert_equal
|
||||||
from ipalib.constants import TYPE_ERROR
|
from ipalib.constants import TYPE_ERROR
|
||||||
from ipalib import frontend, backend, plugable, errors, parameters, config
|
from ipalib import frontend, backend, plugable, errors2, errors, parameters, config
|
||||||
|
|
||||||
|
|
||||||
def test_RULE_FLAG():
|
def test_RULE_FLAG():
|
||||||
@ -86,9 +87,9 @@ class test_Command(ClassChecker):
|
|||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
self.name = name
|
self.name = name
|
||||||
|
|
||||||
def __call__(self, value):
|
def __call__(self, _, value):
|
||||||
if value != self.name:
|
if value != self.name:
|
||||||
return 'must equal %s' % self.name
|
return _('must equal %r') % self.name
|
||||||
|
|
||||||
default_from = parameters.DefaultFrom(
|
default_from = parameters.DefaultFrom(
|
||||||
lambda arg: arg,
|
lambda arg: arg,
|
||||||
@ -98,11 +99,11 @@ class test_Command(ClassChecker):
|
|||||||
|
|
||||||
class example(self.cls):
|
class example(self.cls):
|
||||||
takes_options = (
|
takes_options = (
|
||||||
frontend.Param('option0', Rule('option0'),
|
parameters.Str('option0', Rule('option0'),
|
||||||
normalizer=normalizer,
|
normalizer=normalizer,
|
||||||
default_from=default_from,
|
default_from=default_from,
|
||||||
),
|
),
|
||||||
frontend.Param('option1', Rule('option1'),
|
parameters.Str('option1', Rule('option1'),
|
||||||
normalizer=normalizer,
|
normalizer=normalizer,
|
||||||
default_from=default_from,
|
default_from=default_from,
|
||||||
),
|
),
|
||||||
@ -224,17 +225,13 @@ class test_Command(ClassChecker):
|
|||||||
"""
|
"""
|
||||||
assert 'convert' in self.cls.__public__ # Public
|
assert 'convert' in self.cls.__public__ # Public
|
||||||
kw = dict(
|
kw = dict(
|
||||||
option0='option0',
|
option0=u'1.5',
|
||||||
option1='option1',
|
option1=u'7',
|
||||||
)
|
)
|
||||||
expected = dict(kw)
|
|
||||||
expected.update(dict(option0=u'option0', option1=u'option1'))
|
|
||||||
o = self.subcls()
|
o = self.subcls()
|
||||||
o.finalize()
|
o.finalize()
|
||||||
for (key, value) in o.convert(**kw).iteritems():
|
for (key, value) in o.convert(**kw).iteritems():
|
||||||
v = expected[key]
|
assert_equal(unicode(kw[key]), value)
|
||||||
assert value == v
|
|
||||||
assert type(value) is type(v)
|
|
||||||
|
|
||||||
def test_normalize(self):
|
def test_normalize(self):
|
||||||
"""
|
"""
|
||||||
@ -266,7 +263,7 @@ class test_Command(ClassChecker):
|
|||||||
sub = self.subcls()
|
sub = self.subcls()
|
||||||
sub.finalize()
|
sub.finalize()
|
||||||
|
|
||||||
# Check with valid args
|
# Check with valid values
|
||||||
okay = dict(
|
okay = dict(
|
||||||
option0=u'option0',
|
option0=u'option0',
|
||||||
option1=u'option1',
|
option1=u'option1',
|
||||||
@ -274,13 +271,13 @@ class test_Command(ClassChecker):
|
|||||||
)
|
)
|
||||||
sub.validate(**okay)
|
sub.validate(**okay)
|
||||||
|
|
||||||
# Check with an invalid arg
|
# Check with an invalid value
|
||||||
fail = dict(okay)
|
fail = dict(okay)
|
||||||
fail['option0'] = u'whatever'
|
fail['option0'] = u'whatever'
|
||||||
e = raises(errors.RuleError, sub.validate, **fail)
|
e = raises(errors2.ValidationError, sub.validate, **fail)
|
||||||
assert e.name == 'option0'
|
assert_equal(e.name, 'option0')
|
||||||
assert e.value == u'whatever'
|
assert_equal(e.value, u'whatever')
|
||||||
assert e.error == 'must equal option0'
|
assert_equal(e.error, u"must equal 'option0'")
|
||||||
assert e.rule.__class__.__name__ == 'Rule'
|
assert e.rule.__class__.__name__ == 'Rule'
|
||||||
assert e.index is None
|
assert e.index is None
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user