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

TST: Add unit test and testfile for enums

parent dda6764d
No related branches found
No related tags found
2 merge requests!39Release 0.4.0,!33F json schema datamodel
{
"title": "Dataset",
"description": "Some description",
"type": "object",
"properties": {
"license": {
"type": "string",
"enum": ["CC-BY", "CC-BY-SA", "CC0", "restricted access"]
}
},
"required": ["license"]
}
......@@ -126,3 +126,25 @@ def test_required_no_list():
os.path.join(FILEPATH,
"datamodel_required_no_list.schema.json"))
assert "'Dataset' is not of type 'array'" in str(err.value)
def test_enum():
"""Enums are represented in references to records of a specific type."""
# @author Florian Spreckelsen
# @date 2022-03-16
model = parse_model_from_json_schema(os.path.join(
FILEPATH, "datamodel_enum_prop.schema.json"))
licenses = ["CC-BY", "CC-BY-SA", "CC0", "restricted access"]
for name in ["Dataset", "license"] + licenses:
assert name in model
assert isinstance(model["Dataset"], db.RecordType)
assert model["Dataset"].get_property("license") is not None
assert model["Dataset"].get_property("license").datatype == "license"
assert isinstance(model["license"], db.RecordType)
for name in licenses:
assert isinstance(model[name], db.Record)
assert len(model[name].parents) == 1
assert model[name].has_parent(model["license"])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment