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']
|
||||
properties[prop] = self.convert_properties(properties[prop], dict_valueschema)
|
||||
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)
|
||||
|
||||
elif prop_type == 'list':
|
||||
|
@ -135,8 +135,8 @@ users_schema = {
|
||||
'type': 'dict',
|
||||
# Keyed by Node ID of the video asset. MongoDB doesn't support using
|
||||
# ObjectIds as key, so we cast them to string instead.
|
||||
'keyschema': {'type': 'string'},
|
||||
'valueschema': {
|
||||
'keysrules': {'type': 'string'},
|
||||
'valuesrules': {
|
||||
'type': 'dict',
|
||||
'schema': {
|
||||
'progress_in_sec': {'type': 'float', 'min': 0},
|
||||
|
@ -11,12 +11,11 @@ ATTACHMENT_SLUG_REGEX = r'[a-zA-Z0-9_\-]+'
|
||||
|
||||
attachments_embedded_schema = {
|
||||
'type': 'dict',
|
||||
# TODO: will be renamed to 'keyschema' in Cerberus 1.0
|
||||
'keyschema': {
|
||||
'keysrules': {
|
||||
'type': 'string',
|
||||
'regex': '^%s$' % ATTACHMENT_SLUG_REGEX,
|
||||
},
|
||||
'valueschema': {
|
||||
'valuesrules': {
|
||||
'type': 'dict',
|
||||
'schema': {
|
||||
'oid': {
|
||||
|
@ -19,10 +19,19 @@ def attachment_form_group_create(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.
|
||||
fake_schema = {
|
||||
'slug': schema_prop['keyschema'],
|
||||
'oid': schema_prop['valueschema']['schema']['oid'],
|
||||
'slug': keysrules,
|
||||
'oid': valuesrules['schema']['oid'],
|
||||
}
|
||||
file_select_form_group = build_file_select_form(fake_schema)
|
||||
return file_select_form_group
|
||||
|
@ -63,8 +63,8 @@ class UpgradeAttachmentSchemaTest(AbstractPillarTest):
|
||||
"url": {"type": "string"},
|
||||
"attachments": {
|
||||
"type": "dict",
|
||||
"keyschema": {"type": "string", "regex": "^[a-zA-Z0-9_ ]+$"},
|
||||
"valueschema": {
|
||||
"keysrules": {"type": "string", "regex": "^[a-zA-Z0-9_ ]+$"},
|
||||
"valuesrules": {
|
||||
"type": "dict",
|
||||
"schema": {
|
||||
"oid": {"type": "objectid", "required": True},
|
||||
|
Loading…
x
Reference in New Issue
Block a user