Skip to content
Snippets Groups Projects
Commit bbc92851 authored by florian's avatar florian
Browse files

TST: Add unittest for json schema without top-level entity

parent 224fa6a3
No related branches found
No related tags found
2 merge requests!73MAINT: change wording of TableImporter argument and allow converters and...,!72Extend json-schema model parser
......@@ -181,7 +181,7 @@ def parse_model_from_json_schema(filename: str, top_level_recordtype: bool = Tru
# @review Daniel Hornung 2022-02-18
parser = JsonSchemaParser()
return parser.parse_model_from_json_schema(filename)
return parser.parse_model_from_json_schema(filename, top_level_recordtype)
class Parser(object):
......
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://my-schema-id.net",
"type": "object",
"definitions": {
"uuid": {
"type": [
"string",
"null"
],
"pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
},
"datetime": {
"type": "string",
"format": "date-time"
}
},
"properties": {
{
"title": "Dataset1",
"description": "Some description",
"type": "object",
"properties": {
"title": {
"type": "string",
"description": "full dataset title"
},
"campaign": {
"type": "string",
"description": "FIXME"
},
"number_prop": {
"type": "number",
"description": "Some float property"
}
},
"required": ["title", "number_prop"]
}
}
}
......@@ -356,3 +356,8 @@ def test_name_property():
assert str(err.value).startswith(
"The 'name' property must be string-typed, otherwise it cannot be identified with CaosDB's "
"name property.")
def test_no_toplevel_entity():
model = parse_model_from_json_schema(os.path.join(
FILEPATH, "datamodel_no_toplevel_entity.schema.json"), top_level_recordtype=False)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment