From 8304243264fd9cda478d67d387a7c7b66b3fdd7c Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Fri, 16 Feb 2024 10:53:01 -0500 Subject: [PATCH] TEST: Update expected regexes for stem rules --- .../bidsschematools/tests/test_rules.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tools/schemacode/bidsschematools/tests/test_rules.py b/tools/schemacode/bidsschematools/tests/test_rules.py index 693c4b24fe..529c8e779a 100644 --- a/tools/schemacode/bidsschematools/tests/test_rules.py +++ b/tools/schemacode/bidsschematools/tests/test_rules.py @@ -84,7 +84,7 @@ 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|\.md)", + "regex": r"(?s:README)(?P|\.md)\Z", "mandatory": True, } @@ -92,7 +92,21 @@ def test_stem_rule(): {"stem": "participants", "level": "optional", "extensions": [".tsv", ".json"]} ) assert rules._stem_rule(rule) == { - "regex": r"participants(?P\.tsv|\.json)", + "regex": r"(?s:participants)(?P\.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"(?Pphenotype)/(?s:.*)(?P\.tsv|\.json)\Z", "mandatory": False, }