diff --git a/unittests/test_json_schema_exporter.py b/unittests/test_json_schema_exporter.py index b6ef35e6f5080c11971e8b1e1a7ffb610b8352e5..18b7a418d2d491c64569763775052addc8dfcebc 100644 --- a/unittests/test_json_schema_exporter.py +++ b/unittests/test_json_schema_exporter.py @@ -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))