mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
frontend: remove the unused Command.soft_validate method
https://fedorahosted.org/freeipa/ticket/4739 Reviewed-By: David Kupka <dkupka@redhat.com>
This commit is contained in:
parent
2f6b333187
commit
13b010685b
@ -35,7 +35,7 @@ from ipalib.parameters import Password # pylint: disable=unused-import
|
||||
from ipalib.output import Output, Entry, ListOfEntries
|
||||
from ipalib.text import _
|
||||
from ipalib.errors import (ZeroArgumentError, MaxArgumentError, OverlapError,
|
||||
VersionError, OptionError, InvocationError,
|
||||
VersionError, OptionError,
|
||||
ValidationError, ConversionError)
|
||||
from ipalib import errors, messages
|
||||
from ipalib.request import context, context_frame
|
||||
@ -467,19 +467,6 @@ class Command(HasParam):
|
||||
def add_message(self, message):
|
||||
self.context.__messages.append(message)
|
||||
|
||||
def soft_validate(self, values):
|
||||
errors = dict()
|
||||
for p in self.params():
|
||||
try:
|
||||
value = values.get(p.name)
|
||||
values[p.name] = p(value, **values)
|
||||
except InvocationError as e:
|
||||
errors[p.name] = str(e)
|
||||
return dict(
|
||||
values=values,
|
||||
errors=errors,
|
||||
)
|
||||
|
||||
def _repr_iter(self, **params):
|
||||
"""
|
||||
Iterate through ``repr()`` of *safe* values of args and options.
|
||||
|
@ -402,35 +402,6 @@ class test_Command(ClassChecker):
|
||||
for o in items:
|
||||
assert type(o) is output.Output
|
||||
|
||||
def test_soft_validate(self):
|
||||
"""
|
||||
Test the `ipalib.frontend.Command.soft_validate` method.
|
||||
"""
|
||||
class api(object):
|
||||
env = config.Env(context='cli')
|
||||
@staticmethod
|
||||
def is_production_mode():
|
||||
return False
|
||||
class user_add(frontend.Command):
|
||||
takes_args = parameters.Str('uid',
|
||||
normalizer=lambda value: value.lower(),
|
||||
default_from=lambda givenname, sn: givenname[0] + sn,
|
||||
)
|
||||
|
||||
takes_options = ('givenname', 'sn')
|
||||
|
||||
cmd = user_add(api)
|
||||
cmd.finalize()
|
||||
assert list(cmd.params) == ['givenname', 'sn', 'uid', 'version']
|
||||
ret = cmd.soft_validate({})
|
||||
assert sorted(ret['values']) == ['version']
|
||||
assert sorted(ret['errors']) == ['givenname', 'sn', 'uid']
|
||||
assert cmd.soft_validate(dict(givenname=u'First', sn=u'Last')) == dict(
|
||||
values=dict(givenname=u'First', sn=u'Last', uid=u'flast',
|
||||
version=None),
|
||||
errors=dict(),
|
||||
)
|
||||
|
||||
def test_convert(self):
|
||||
"""
|
||||
Test the `ipalib.frontend.Command.convert` method.
|
||||
|
Loading…
Reference in New Issue
Block a user