Skip to content
Snippets Groups Projects
Commit 335b7350 authored by florian's avatar florian
Browse files

TST: Extend unittest

parent c8c055c4
No related branches found
No related tags found
2 merge requests!89ENH: JsonSchemaExporter accepts do_not_create parameter.,!81F schema export references
......@@ -270,8 +270,8 @@ def test_rt_with_list_props():
@patch("linkahead.execute_query", new=Mock(side_effect=_mock_execute_query))
def test_rt_with_references():
"""References and lists of references will come later, so test if the errors
are thrown correctly.
"""References and lists of references to files will come later, so test if
the errors are thrown correctly.
"""
......@@ -280,11 +280,35 @@ def test_rt_with_references():
schema = rtjs(rt)
props = schema["properties"]
assert "RefProp" in props
assert "enum" in props["RefProp"]
assert isinstance(props["RefProp"]["enum"], list)
assert len(props["RefProp"]["enum"]) == len(
db.execute_query("SELECT name, id FROM RECORD")) + len(
db.execute_query("SELECT name, id FROM FILE"))
assert "oneOf" not in props["RefProp"]
rt = db.RecordType()
rt.add_property(name="RefProp", datatype="OtherType")
schema = rtjs(rt)
props = schema["properties"]
assert "RefProp" in props
assert "oneOf" in props["RefProp"]
assert len(props["RefProp"]["oneOf"]) == 2
enum_index = 0
if "enum" not in props["RefProp"]["oneOf"][enum_index]:
# We can't really require the order here, so we just know that one of
# the two elements must be the enum, the other the object.
enum_index = 1 - enum_index
assert "enum" in props["RefProp"]["oneOf"][enum_index]
assert isinstance(props["RefProp"]["oneOf"][enum_index]["enum"], list)
assert len(props["RefProp"]["oneOf"][enum_index]["enum"]) == 3
assert "100, otherA" in props["RefProp"]["oneOf"][enum_index]["enum"]
assert "101, otherB" in props["RefProp"]["oneOf"][enum_index]["enum"]
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"
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