Skip to content

Commit

Permalink
TEST: Update expected regexes for stem rules
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed Apr 26, 2024
1 parent 3c2b821 commit 8304243
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions tools/schemacode/bidsschematools/tests/test_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,29 @@ def test_split_inheritance_rules():
def test_stem_rule():
rule = Namespace.build({"stem": "README", "level": "required", "extensions": ["", ".md"]})
assert rules._stem_rule(rule) == {
"regex": r"README(?P<extension>|\.md)",
"regex": r"(?s:README)(?P<extension>|\.md)\Z",
"mandatory": True,
}

rule = Namespace.build(
{"stem": "participants", "level": "optional", "extensions": [".tsv", ".json"]}
)
assert rules._stem_rule(rule) == {
"regex": r"participants(?P<extension>\.tsv|\.json)",
"regex": r"(?s:participants)(?P<extension>\.tsv|\.json)\Z",
"mandatory": False,
}

# Wildcard stem, with datatype
rule = Namespace.build(
{
"stem": "*",
"datatypes": ["phenotype"],
"level": "optional",
"extensions": [".tsv", ".json"],
}
)
assert rules._stem_rule(rule) == {
"regex": r"(?P<datatype>phenotype)/(?s:.*)(?P<extension>\.tsv|\.json)\Z",
"mandatory": False,
}

Expand Down

0 comments on commit 8304243

Please sign in to comment.