Skip to content

Commit

Permalink
Add test to force required blocks for certain types of metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamJamieson committed Nov 11, 2024
1 parent f478a6f commit 0943805
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tests/test_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,15 @@ def test_metadata_force_required(schema):
def callback(node):
if isinstance(node, Mapping) and "properties" in node:
for prop_name, prop in node["properties"].items():
# Test that if a subnode has a required list, that the parent has a required list
if isinstance(prop, Mapping) and "required" in prop:
assert "required" in node
assert prop_name in node["required"]

# Test that if a subnode has certain metadata entries, that the parent has a required list
for metadata in METADATA_FORCING_REQUIRED:
if isinstance(prop, Mapping) and metadata in prop:
assert "required" in node
assert "required" in node, f"metadata {metadata} in {prop_name} requires required list"
assert prop_name in node["required"]

asdf.treeutil.walk(schema, callback)
Expand Down

0 comments on commit 0943805

Please sign in to comment.