diff --git a/unittests/test_json_schema_exporter.py b/unittests/test_json_schema_exporter.py index 18b7a418d2d491c64569763775052addc8dfcebc..3dafab2d72cb62fb8dfedf43f5eb2ef45c7721c9 100644 --- a/unittests/test_json_schema_exporter.py +++ b/unittests/test_json_schema_exporter.py @@ -321,10 +321,27 @@ def test_rt_with_references(): assert "OtherTextProp" in props assert props["OtherTextProp"]["type"] == "string" - rt = db.RecordType() - rt.add_property(name="RefProp", datatype=db.LIST(db.REFERENCE)) + rt = db.RecordType(name="TestType", description="Some description") + rt.add_property(name="RefProp", datatype=db.LIST(db.REFERENCE), + description="I'm a list of references.") schema = rtjs(rt) + assert schema["title"] == rt.name + assert schema["description"] == rt.description + assert "RefProp" in schema["properties"] + ref_prop = schema["properties"]["RefProp"] + assert ref_prop["type"] == "array" + assert "description" in ref_prop + assert ref_prop["description"] == "I'm a list of references." + assert "items" in ref_prop + items = ref_prop["items"] + assert "enum" in items + assert isinstance(items["enum"], list) + assert len(items["enum"]) == len( + db.execute_query("SELECT name, id FROM RECORD")) + len( + db.execute_query("SELECT name, id FROM FILE")) + assert "oneOf" not in items + assert "description" not in items rt = db.RecordType() rt.add_property(name="RefProp", datatype=db.LIST("OtherType"))