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

TST: Test mixed reference and non-ref properties

parent 335b7350
No related branches found
No related tags found
2 merge requests!89ENH: JsonSchemaExporter accepts do_not_create parameter.,!81F schema export references
Pipeline #42742 failed
......@@ -34,6 +34,7 @@ def _mock_execute_query(query_string, unique=False, **kwargs):
all_records = db.Container()
all_files = db.Container()
other_type_rt = db.RecordType(name="OtherType")
other_type_rt.add_property(name="IntegerProp", datatype=db.INTEGER, importance=db.OBLIGATORY)
other_type_records = db.Container().extend([
db.Record(id=100, name="otherA").add_parent(other_type_rt),
db.Record(id=101, name="otherB").add_parent(other_type_rt),
......@@ -290,6 +291,7 @@ def test_rt_with_references():
rt = db.RecordType()
rt.add_property(name="RefProp", datatype="OtherType")
rt.add_property(name="OtherTextProp", datatype=db.TEXT)
schema = rtjs(rt)
props = schema["properties"]
......@@ -309,6 +311,15 @@ def test_rt_with_references():
assert "102" in props["RefProp"]["oneOf"][enum_index]["enum"]
# the other element of oneOf is the OtherType object
assert props["RefProp"]["oneOf"][1 - enum_index]["type"] == "object"
other_props = props["RefProp"]["oneOf"][1 - enum_index]["properties"]
assert "IntegerProp" in other_props
assert other_props["IntegerProp"]["type"] == "integer"
assert "required" in props["RefProp"]["oneOf"][1 - enum_index]
assert len(props["RefProp"]["oneOf"][1 - enum_index]["required"]) == 1
assert "IntegerProp" in props["RefProp"]["oneOf"][1 - enum_index]["required"]
# The other prop also works as before
assert "OtherTextProp" in props
assert props["OtherTextProp"]["type"] == "string"
rt = db.RecordType()
rt.add_property(name="RefProp", datatype=db.LIST(db.REFERENCE))
......
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