def test_object_instead_of_reference_in_list_triggers_specificationwarning():
with pytest.warns(oparl.SpecificationWarning) as record:
obj = oparl.from_json('''{
"id": "object-with-object-instead-of-reference-in-list",
"type": "https://schema.oparl.org/1.0/System",
"otherOparlVersions": [{
"id": "does-not-exist",
"type": "https://schema.oparl.org/1.0/System"
}]
}''')
assert len(record) == 1
assert 'must contain references' in str(record[0].message)
others = obj['otherOparlVersions']
assert isinstance(others, list)
assert len(others) == 1
assert isinstance(others[0], oparl.objects.System)
assert others[0]['id'] == 'does-not-exist'
评论列表
文章目录