Skip to content
Snippets Groups Projects
Commit e7b65817 authored by Florian Spreckelsen's avatar Florian Spreckelsen
Browse files

TST: Add schema validation tests

parent e447e794
No related branches found
No related tags found
2 merge requests!178FIX: #96 Better error output for crawl.py script.,!163F dict heuristic
......@@ -4,6 +4,11 @@ cfood:
$ref:
"#/$defs/converter"
$defs:
parents:
description: Parents for this record are given here as a list of names.
type: array
items:
type: string
converter:
properties:
type:
......@@ -38,6 +43,7 @@ cfood:
- H5Dataset
- H5Group
- H5Ndarray
- PropertiesFromDictElement
description: Type of this converter node.
match:
description: typically a regexp which is matched to a structure element name
......@@ -48,15 +54,42 @@ cfood:
match_value:
description: a regexp that is matched to the value of a key-value pair
type: string
records:
description: This field is used to define new records or to modify records which have been defined on a higher level.
record_from_dict:
description: Only relevant for PropertiesFromDictElement. Specify the root record which is generated from the contained dictionary.
type: object
required:
- variable_name
properties:
parents:
description: Parents for this record are given here as a list of names.
variable_name:
description: Name of the record by which it can be accessed in the cfood definiton. Can also be the name of an existing record in which case that record will be treted by the PropertiesFromDictConverter.
type: string
properties_blacklist:
description: List of keys to be ignored in the automatic treatment. They will be ignored on all levels of the dictionary.
type: array
items:
type: string
references:
description: List of keys that will be transformed into named reference properties.
type: object
additionalProperties:
type: object
properties:
parents:
$ref:
"#/$defs/parents"
name:
description: Nmae of this record. If none is given, variable_name is used.
type: string
parents:
$ref:
"#/$defs/parents"
records:
description: This field is used to define new records or to modify records which have been defined on a higher level.
type: object
properties:
parents:
$ref:
"#/$defs/parents"
additionalProperties:
oneOf:
- type: object
......@@ -78,3 +111,15 @@ cfood:
additionalProperties:
$ref:
"#/$defs/converter"
if:
properties:
type:
const:
PropertiesFromDictElement
then:
required:
- type
- record_from_dict
else:
required:
- type
RecordFromDictElement:
type: PropertiesFromDictElement
match: "(.*)"
subtree:
AnotherElement:
type: Text
match_name: "(.*)"
RecordFromDictElement:
type: PropertiesFromDictElement
record_from_dict:
parents:
- MyType1
- MyType2
match: "(.*)"
subtree:
AnotherElement:
type: Text
match_name: "(.*)"
PropertiesFromDictElement:
type: PropertiesFromDictElement
match: ".*"
record_from_dict:
variable_name: MyRec
parents:
- MyType1
- MyType2
references:
author:
parents:
- Person
......@@ -27,6 +27,13 @@ def rfp(*pathcomponents):
def test_schema_validation():
load_definition(rfp("scifolder_cfood.yml"))
load_definition(rfp("scifolder_extended.yml"))
load_definition(rfp("record_from_dict_cfood.yml"))
with raises(ValidationError, match=".*enum.*"):
load_definition(rfp("broken_cfoods", "broken1.yml"))
with raises(ValidationError, match=".*required.*"):
load_definition(rfp("broken_cfoods", "broken_record_from_dict.yml"))
with raises(ValidationError, match=".*required.*"):
load_definition(rfp("broken_cfoods", "broken_record_from_dict_2.yml"))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment