Cerberus 1.3 renamed '{value,key}schema' to '{values,keys}rules'
'valueschema' and 'keyschema' have been replaced by 'valuesrules' and 'keysrules'. Note the change from 2x singular ('value' and 'schema') to 2x plural ('values' and 'rules').
This commit is contained in:
parent
dd5cd5b61a
commit
8b42e88817
@ -29,7 +29,11 @@ class ValidateCustomFields(Validator):
|
|||||||
dict_valueschema = schema_prop['schema']
|
dict_valueschema = schema_prop['schema']
|
||||||
properties[prop] = self.convert_properties(properties[prop], dict_valueschema)
|
properties[prop] = self.convert_properties(properties[prop], dict_valueschema)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
dict_valueschema = schema_prop['valueschema']
|
# Cerberus 1.3 changed valueschema to valuesrules.
|
||||||
|
dict_valueschema = schema_prop.get('valuesrules') or \
|
||||||
|
schema_prop.get('valueschema')
|
||||||
|
if dict_valueschema is None:
|
||||||
|
raise KeyError(f"missing 'valuesrules' key in schema of property {prop}")
|
||||||
self.convert_dict_values(properties[prop], dict_valueschema)
|
self.convert_dict_values(properties[prop], dict_valueschema)
|
||||||
|
|
||||||
elif prop_type == 'list':
|
elif prop_type == 'list':
|
||||||
|
@ -135,8 +135,8 @@ users_schema = {
|
|||||||
'type': 'dict',
|
'type': 'dict',
|
||||||
# Keyed by Node ID of the video asset. MongoDB doesn't support using
|
# Keyed by Node ID of the video asset. MongoDB doesn't support using
|
||||||
# ObjectIds as key, so we cast them to string instead.
|
# ObjectIds as key, so we cast them to string instead.
|
||||||
'keyschema': {'type': 'string'},
|
'keysrules': {'type': 'string'},
|
||||||
'valueschema': {
|
'valuesrules': {
|
||||||
'type': 'dict',
|
'type': 'dict',
|
||||||
'schema': {
|
'schema': {
|
||||||
'progress_in_sec': {'type': 'float', 'min': 0},
|
'progress_in_sec': {'type': 'float', 'min': 0},
|
||||||
|
@ -11,12 +11,11 @@ ATTACHMENT_SLUG_REGEX = r'[a-zA-Z0-9_\-]+'
|
|||||||
|
|
||||||
attachments_embedded_schema = {
|
attachments_embedded_schema = {
|
||||||
'type': 'dict',
|
'type': 'dict',
|
||||||
# TODO: will be renamed to 'keyschema' in Cerberus 1.0
|
'keysrules': {
|
||||||
'keyschema': {
|
|
||||||
'type': 'string',
|
'type': 'string',
|
||||||
'regex': '^%s$' % ATTACHMENT_SLUG_REGEX,
|
'regex': '^%s$' % ATTACHMENT_SLUG_REGEX,
|
||||||
},
|
},
|
||||||
'valueschema': {
|
'valuesrules': {
|
||||||
'type': 'dict',
|
'type': 'dict',
|
||||||
'schema': {
|
'schema': {
|
||||||
'oid': {
|
'oid': {
|
||||||
|
@ -19,10 +19,19 @@ def attachment_form_group_create(schema_prop):
|
|||||||
|
|
||||||
|
|
||||||
def _attachment_build_single_field(schema_prop):
|
def _attachment_build_single_field(schema_prop):
|
||||||
|
# 'keyschema' was renamed to 'keysrules' in Cerberus 1.3, but our data may still have the old
|
||||||
|
# names. Same for 'valueschema' and 'valuesrules'.
|
||||||
|
keysrules = schema_prop.get('keysrules') or schema_prop.get('keyschema')
|
||||||
|
if keysrules is None:
|
||||||
|
raise KeyError(f"missing 'keysrules' key in schema {schema_prop}")
|
||||||
|
valuesrules = schema_prop.get('valuesrules') or schema_prop.get('valueschema')
|
||||||
|
if valuesrules is None:
|
||||||
|
raise KeyError(f"missing 'valuesrules' key in schema {schema_prop}")
|
||||||
|
|
||||||
# Ugly hard-coded schema.
|
# Ugly hard-coded schema.
|
||||||
fake_schema = {
|
fake_schema = {
|
||||||
'slug': schema_prop['keyschema'],
|
'slug': keysrules,
|
||||||
'oid': schema_prop['valueschema']['schema']['oid'],
|
'oid': valuesrules['schema']['oid'],
|
||||||
}
|
}
|
||||||
file_select_form_group = build_file_select_form(fake_schema)
|
file_select_form_group = build_file_select_form(fake_schema)
|
||||||
return file_select_form_group
|
return file_select_form_group
|
||||||
|
@ -63,8 +63,8 @@ class UpgradeAttachmentSchemaTest(AbstractPillarTest):
|
|||||||
"url": {"type": "string"},
|
"url": {"type": "string"},
|
||||||
"attachments": {
|
"attachments": {
|
||||||
"type": "dict",
|
"type": "dict",
|
||||||
"keyschema": {"type": "string", "regex": "^[a-zA-Z0-9_ ]+$"},
|
"keysrules": {"type": "string", "regex": "^[a-zA-Z0-9_ ]+$"},
|
||||||
"valueschema": {
|
"valuesrules": {
|
||||||
"type": "dict",
|
"type": "dict",
|
||||||
"schema": {
|
"schema": {
|
||||||
"oid": {"type": "objectid", "required": True},
|
"oid": {"type": "objectid", "required": True},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user