Skip to content
Snippets Groups Projects

F schema export references

Merged Florian Spreckelsen requested to merge f-schema-export-references into dev
All threads resolved!
1 file
+ 11
0
Compare changes
  • Side-by-side
  • Inline
@@ -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))
Loading