Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a few more tests for the schema #1963

Merged
merged 1 commit into from
Nov 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion tools/schemacode/bidsschematools/data/tests/test_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def test_rule_objects(schema_obj):
is_list = False

for i_use, use in enumerate(instance):
assert isinstance(use, str)
if use == "derivatives":
# Skip derivatives dirs, because the dir is treated as a "use" instead.
continue
Expand All @@ -81,9 +82,21 @@ def test_rule_objects(schema_obj):
object_values = [
value["value"] for value in schema_obj["objects"][object_type].values()
]
else:
elif object_type in [
"columns",
"common_principles",
"datatypes",
"entities",
"enums",
"files",
"formats",
"metadata",
"modalities",
]:
# But other object types are referenced via their keys
object_values = list(schema_obj["objects"][object_type].keys())
else:
raise AssertionError(f"Object type {object_type} not implemented.")
Comment on lines +98 to +99
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes more sense to me to put up right under for object_type in schema_obj.objects: rather than checking repeatedly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it more of defensive coding to close up if/elif chain to not leave it "untested" -- code should never run into it (it is exception)


# Build a list of items mentioned in rules, but not found in objects.
if use not in object_values:
Expand Down