Skip to content

Commit

Permalink
add test that ref containing objects do not contain other items
Browse files Browse the repository at this point in the history
  • Loading branch information
braingram committed Dec 10, 2024
1 parent 689831d commit 52a9636
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/test_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,3 +295,29 @@ def callback(node, nvarchars=None):
assert node["maxLength"] == v, f"archive_catalog nvarchar does not match maxLength in schema {uri}"

asdf.treeutil.walk(schema, callback)


# don't test tvac or fps schemas as they are static
@pytest.mark.parametrize(
"uri",
[
uri
for uri in SCHEMA_URIS
if not uri.startswith("asdf://stsci.edu/datamodels/roman/schemas/fps/")
and not uri.startswith("asdf://stsci.edu/datamodels/roman/schemas/tvac/")
],
)
def test_ref_loneliness(uri):
"""
An object with a $ref should contain no other items
"""
schema = asdf.schema.load_schema(uri)

def callback(node):
if not isinstance(node, dict):
return
if "$ref" not in node:
return
assert len(node) == 1

asdf.treeutil.walk(schema, callback)

0 comments on commit 52a9636

Please sign in to comment.