[Freeipa-devel] [PATCH] 317 Improve StrEnum validation error message

Jan Cholasta jcholast at redhat.com
Mon Oct 1 09:16:13 UTC 2012


Dne 1.10.2012 10:05, Martin Kosek napsal(a):
> On 10/01/2012 09:19 AM, Jan Cholasta wrote:
>> Dne 27.9.2012 14:28, Martin Kosek napsal(a):
>>> Do not print list of possible values as "%r" but simply as a list
>>> of quoted values which should make it easier to read for users.
>>> Also add a special case when there is just one allowed value.
>>>
>>> https://fedorahosted.org/freeipa/ticket/2869
>>>
>>>
>>> Examples of the improved Enum validation error messages:
>>>
>>> # ipa automember-add foo --type=bar
>>> ipa: ERROR: invalid 'type': must be one of 'group', 'hostgroup'
>>>
>>> # ipa trust-add foo --type=foo
>>> ipa: ERROR: invalid 'type': must be 'ad'
>>>
>>> Martin
>>>
>>
>> IMO instead of doing this:
>>
>> +            else:
>> +                return _("must be empty")
>>
>> we should not allow empty "values" kwarg in Enum at all, i.e. check that
>> len(self.values) > 0 in Enum.__init__.
>
> Right, I fixed it. I also added a relevant test case to our unit tests.
>
>>
>> Also, I have opened <https://fedorahosted.org/freeipa/ticket/3121>, as we use
>> %r in more places where we should not.
>>
>> Honza
>>
>
> Thanks. New patch attached.
>
> Martin
>

ACK.

Honza

-- 
Jan Cholasta




More information about the Freeipa-devel mailing list