Disable custom vocab enforcement. Custom values for open-vocab

properties are now always accepted and not considered
customizations (has_custom will be False).  Just commented out
the enforcement code and xfail'd the unit tests, which makes it
easy to reinstate these behaviors later.  It was decided this
is too likely to break user code, and we don't currently have
a way to disallow customizations in other places while still
allowing custom open vocab values.  Safest to always allow
custom open vocab values, for now.
pull/1/head
Michael Chisholm 2021-04-14 12:48:32 -04:00
parent 33128908c7
commit f301bc144f
2 changed files with 15 additions and 5 deletions

View File

@ -690,12 +690,18 @@ class OpenVocabProperty(StringProperty):
value, allow_custom,
)
has_custom = cleaned_value not in self.allowed
# Disabled: it was decided that enforcing this is too strict (might
# break too much user code). Revisit when we have the capability for
# more granular config settings when creating objects.
#
# has_custom = cleaned_value not in self.allowed
#
# if not allow_custom and has_custom:
# raise CustomContentError(
# "custom value in open vocab: '{}'".format(cleaned_value),
# )
if not allow_custom and has_custom:
raise CustomContentError(
"custom value in open vocab: '{}'".format(cleaned_value),
)
has_custom = False
return cleaned_value, has_custom

View File

@ -368,6 +368,10 @@ def test_enum_property_invalid():
enum_prop.clean('z', True)
@pytest.mark.xfail(
reason="Temporarily disabled custom open vocab enforcement",
strict=True
)
@pytest.mark.parametrize(
"vocab", [
['a', 'b', 'c'],