martbab's pull request #51: "Fix failing negative tests for deprecated params" was opened
PR body: """ Fixes https://fedorahosted.org/freeipa/ticket/6190 There is one last failing test. To fix it properly we will have to rework `Parameter.__init__` method, see https://fedorahosted.org/freeipa/ticket/6292 """ See the full pull-request at https://github.com/freeipa/freeipa/pull/51 ... or pull the PR as Git branch: git remote add ghfreeipa https://github.com/freeipa/freeipa git fetch ghfreeipa pull/51/head:pr51 git checkout pr51
From c6cec9e59dd62b5efdb45a8cf413177b517e9c22 Mon Sep 17 00:00:00 2001 From: Martin Babinsky <mbabi...@redhat.com> Date: Tue, 19 Jul 2016 17:05:32 +0200 Subject: [PATCH] raise ValidationError when deprecated param is passed to command https://fedorahosted.org/freeipa/ticket/6190 --- ipalib/parameters.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ipalib/parameters.py b/ipalib/parameters.py index 6917c8d..37f9650 100644 --- a/ipalib/parameters.py +++ b/ipalib/parameters.py @@ -854,6 +854,9 @@ def validate(self, value, supplied=None): if self.required or (supplied and 'nonempty' in self.flags): raise RequirementError(name=self.name) return + if self.deprecated: + raise ValidationError(name=self.get_param_name(), + error=_('this option is deprecated')) if self.multivalue: if type(value) is not tuple: raise TypeError( @@ -876,10 +879,6 @@ def _validate_scalar(self, value, index=None): if error is not None: raise ValidationError(name=self.get_param_name(), error=error) - def _rule_deprecated(self, _, value): - if self.deprecated: - return _('this option is deprecated') - def get_default(self, **kw): """ Return the static default or construct and return a dynamic default.
-- Manage your subscription for the Freeipa-devel mailing list: https://www.redhat.com/mailman/listinfo/freeipa-devel Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code