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

TST: Finalize integration tests for json-schema datamodel parser

parent cdbebd84
No related branches found
No related tags found
2 merge requests!39Release 0.4.0,!33F json schema datamodel
Pipeline #20742 passed
......@@ -47,6 +47,39 @@
{
"title": "TestTypeWithLists",
"type": "object",
"properties": {}
"properties": {
"string_list": {
"type": "array",
"description": "A list of words",
"items": { "type": "string" }
},
"named_int_list": {
"type": "array",
"title": "NamedIntList",
"items": { "type": "integer" }
},
"ListRecordType": {
"type": "array",
"items": { "type": "object", "properties": {} }
},
"NamedReferenceList": {
"type": "array",
"items": {
"title": "ReferencedListTypeWithName",
"type": "object",
"description": "Referenced by a named list-of-references property",
"properties": {
"double_prop": {}
}
}
},
"ListNumberEnum": {
"type": "array",
"items": {
"type": "number",
"enum": [ 1.1, 2.2, 3.3 ]
}
}
}
}
]
......@@ -120,8 +120,10 @@ def test_json_parsed_datamodel():
enum_type = db.execute_query(
f"FIND RECORDTYPE {enum_type_name}", unique=True)
assert len(enum_type.properties) == 0
assert len(db.execute_query(
f"FIND RECORD {enum_type_name}")) == len(enum_names)
enum_records = db.execute_query(f"FIND RECORD {enum_type_name}")
assert len(enum_records) == len(enum_names)
for rec in enum_records:
assert rec.name in enum_names
assert rt2.get_property(enum_type_name) is not None
assert rt2.get_property(enum_type_name).is_reference()
assert rt2.get_property(enum_type_name).name == enum_type.name
......@@ -129,3 +131,44 @@ def test_json_parsed_datamodel():
# Recordtype with lists
rt3 = db.execute_query("FIND RECORDTYPE TestTypeWithLists", unique=True)
assert rt3.get_property("string_list") is not None
assert rt3.get_property("string_list").datatype == db.LIST(db.TEXT)
string_list_prop = db.Property(name="string_list").retrieve()
assert string_list_prop.description == "A list of words"
assert string_list_prop.datatype == db.LIST(db.TEXT)
assert string_list_prop.id == rt3.get_property("string_list").id
assert rt3.get_property("NamedIntList") is not None
assert rt3.get_property("NamedIntList").datatype == db.LIST(db.INTEGER)
# This is a list of a plain references to a specific type
list_rt = db.execute_query("FIND RECORDTYPE ListRecordType", unique=True)
assert len(list_rt.properties) == 0
assert rt3.get_property(list_rt.name) is not None
assert rt3.get_property(list_rt.name).is_reference()
assert rt3.get_property(list_rt.name).datatype == db.LIST(list_rt)
assert rt3.get_property(list_rt.name).id == list_rt.id
# This is a list property of its own, referencing another separate RT
referenced_list_rt = db.execute_query(
"FIND RECORDTYPE ReferencedListTypeWithName", unique=True)
assert referenced_list_rt.description == "Referenced by a named list-of-references property"
assert referenced_list_rt.get_property("double_prop") is not None
assert (referenced_list_rt.get_property("double_prop").id ==
rt1.get_property("double_prop").id)
assert rt3.get_property("NamedReferenceList") is not None
assert rt3.get_property("NamedReferenceList").is_reference()
assert rt3.get_property(
"NamedReferenceList").datatype == db.LIST(referenced_list_rt)
assert rt3.get_property("NamedReferenceList").id != referenced_list_rt.id
enum_type = db.execute_query("FIND RECORDTYPE ListNumberEnum", unique=True)
assert len(enum_type.properties) == 0
enum_names = ["1.1", "2.2", "3.3"]
enum_records = db.execute_query("FIND RECORD ListNumberEnum")
assert len(enum_records) == len(enum_names)
for rec in enum_records:
assert rec.name in enum_names
assert rt3.get_property(enum_type.name) is not None
assert rt3.get_property(enum_type.name).datatype == db.LIST(enum_type)
assert rt3.get_property(enum_type.name).id == enum_type.id
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