|
7 | 7 |
|
8 | 8 | import os
|
9 | 9 |
|
10 |
| -import pytest |
11 | 10 | import datalad.api
|
| 11 | +import pytest |
12 | 12 |
|
13 | 13 | from bids_validator import BIDSValidator
|
14 | 14 |
|
15 | 15 | HOME = os.path.expanduser('~')
|
16 | 16 |
|
17 | 17 | TEST_DATA_DICT = {
|
18 |
| - 'eeg_matchingpennies': ( |
19 |
| - 'https://gin.g-node.org/sappelhoff/eeg_matchingpennies' |
20 |
| - ), |
21 |
| - } |
| 18 | + 'eeg_matchingpennies': ('https://gin.g-node.org/sappelhoff/eeg_matchingpennies'), |
| 19 | +} |
22 | 20 |
|
23 | 21 | EXCLUDE_KEYWORDS = ['git', 'datalad', 'sourcedata', 'bidsignore']
|
24 | 22 |
|
@@ -61,94 +59,112 @@ def test_datasets(validator, fname):
|
61 | 59 | assert validator.is_bids(fname)
|
62 | 60 |
|
63 | 61 |
|
64 |
| -@pytest.mark.parametrize('fname, matches', [ |
65 |
| - ('/T1w.json', True), |
66 |
| - ('/dataset_description.json', True), |
67 |
| - ('/README', True), |
68 |
| - ('/CHANGES', True), |
69 |
| - ('/participants.tsv', True), |
70 |
| - ('/sub-01/anat/sub-01_T1w.nii.gz', False), |
71 |
| -]) |
| 62 | +@pytest.mark.parametrize( |
| 63 | + ('fname', 'matches'), |
| 64 | + [ |
| 65 | + ('/T1w.json', True), |
| 66 | + ('/dataset_description.json', True), |
| 67 | + ('/README', True), |
| 68 | + ('/CHANGES', True), |
| 69 | + ('/participants.tsv', True), |
| 70 | + ('/sub-01/anat/sub-01_T1w.nii.gz', False), |
| 71 | + ], |
| 72 | +) |
72 | 73 | def test_top_level(validator, fname, matches):
|
73 | 74 | """Test that is_top_level returns true for top-level files."""
|
74 | 75 | assert validator.is_top_level(fname) is matches
|
75 | 76 |
|
76 | 77 |
|
77 |
| -@pytest.mark.parametrize('fname, matches', [ |
78 |
| - ('/sourcedata/unstructured_data.nii.gz', True), |
79 |
| - ('/sourcedata/dicom_dir/xyz.dcm', True), |
80 |
| - ('/code/my_analysis/analysis.py', True), |
81 |
| - ('/derivatives/preproc/sub-01/anat/sub-01_desc-preproc_T1w.nii.gz', True), |
82 |
| - ('/stimuli/pic.jpg', True), |
83 |
| - ('/sub-01/anat/sub-01_T1w.nii.gz', False), |
84 |
| -]) |
| 78 | +@pytest.mark.parametrize( |
| 79 | + ('fname', 'matches'), |
| 80 | + [ |
| 81 | + ('/sourcedata/unstructured_data.nii.gz', True), |
| 82 | + ('/sourcedata/dicom_dir/xyz.dcm', True), |
| 83 | + ('/code/my_analysis/analysis.py', True), |
| 84 | + ('/derivatives/preproc/sub-01/anat/sub-01_desc-preproc_T1w.nii.gz', True), |
| 85 | + ('/stimuli/pic.jpg', True), |
| 86 | + ('/sub-01/anat/sub-01_T1w.nii.gz', False), |
| 87 | + ], |
| 88 | +) |
85 | 89 | def test_associated_data(validator, fname, matches):
|
86 | 90 | """Test that is_associated_data returns true for associated data."""
|
87 | 91 | assert validator.is_associated_data(fname) is matches
|
88 | 92 |
|
89 | 93 |
|
90 |
| -@pytest.mark.parametrize('fname, matches', [ |
91 |
| - ('/sub-01/ses-1/sub-01_ses-1_scans.tsv', True), |
92 |
| - ('/sub-01/ses-1/sub-01_ses-1_scans.json', True), |
93 |
| - ('/sub-01/sub-01_scans.tsv', True), |
94 |
| - ('/sub-01/sub-01_scans.json', True), |
95 |
| - ('/sub-01/ses-1/sub-01_ses-1_task-rest_bold.json', True), |
96 |
| - ('/sub-01/sub-01_task-rest_bold.json', True), |
97 |
| - ('/sub-01/ses-1/sub-01_ses-1_asl.json', True), |
98 |
| - ('/sub-01/sub-01_asl.json', True), |
99 |
| - ('/sub-01/ses-1/sub-01_ses-1_pet.json', True), |
100 |
| - ('/sub-01/sub-01_pet.json', True), |
101 |
| - ('/sub-01/ses-1/sub-01_ses-1_proc-test_channels.tsv', True), |
102 |
| - ('/sub-01/ses-1/sub-01_ses-1_channels.json', True), |
103 |
| - ('/sub-01/sub-01_proc-test_channels.tsv', True), |
104 |
| - ('/sub-01/sub-01_channels.json', True), |
105 |
| - ('/sub-01/ses-1/sub-01_ses-1_space-CapTrak_electrodes.tsv', True), |
106 |
| - ('/sub-01/ses-1/sub-01_ses-1_coordsystem.json', True), |
107 |
| - ('/sub-01/sub-01_space-CapTrak_electrodes.tsv', True), |
108 |
| - ('/sub-01/sub-01_coordsystem.json', True), |
109 |
| - ('/sub-01/ses-1/sub-01_ses-1_motion.json', True), |
110 |
| - ('/sub-01/sub-01_motion.json', True), |
111 |
| - ('/sub-01/ses-1/sub-01_ses-1_TEM.json', True), |
112 |
| - ('/sub-01/sub-01_TEM.json', True), |
113 |
| - ('/sub-01/ses-1/sub-01_ses-1_nirs.json', True), |
114 |
| - ('/sub-01/sub-01_nirs.json', True), |
115 |
| - # Mismatch sessions |
116 |
| - ('/sub-01/sub-01_ses-1_scans.tsv', False), |
117 |
| - ('/sub-01/sub-01_ses-1_scans.json', False), |
118 |
| - ('/sub-01/ses-1/sub-01_ses-2_scans.tsv', False), |
119 |
| - # File-level |
120 |
| - ('/sub-01/ses-1/func/sub-01_ses-1_task-rest_bold.nii.gz', False), |
121 |
| - ('/sub-01/anat/sub-01_T1w.nii.gz', False), |
122 |
| -]) |
| 94 | +@pytest.mark.parametrize( |
| 95 | + ('fname', 'matches'), |
| 96 | + [ |
| 97 | + ('/sub-01/ses-1/sub-01_ses-1_scans.tsv', True), |
| 98 | + ('/sub-01/ses-1/sub-01_ses-1_scans.json', True), |
| 99 | + ('/sub-01/sub-01_scans.tsv', True), |
| 100 | + ('/sub-01/sub-01_scans.json', True), |
| 101 | + ('/sub-01/ses-1/sub-01_ses-1_task-rest_bold.json', True), |
| 102 | + ('/sub-01/sub-01_task-rest_bold.json', True), |
| 103 | + ('/sub-01/ses-1/sub-01_ses-1_asl.json', True), |
| 104 | + ('/sub-01/sub-01_asl.json', True), |
| 105 | + ('/sub-01/ses-1/sub-01_ses-1_pet.json', True), |
| 106 | + ('/sub-01/sub-01_pet.json', True), |
| 107 | + ('/sub-01/ses-1/sub-01_ses-1_proc-test_channels.tsv', True), |
| 108 | + ('/sub-01/ses-1/sub-01_ses-1_channels.json', True), |
| 109 | + ('/sub-01/sub-01_proc-test_channels.tsv', True), |
| 110 | + ('/sub-01/sub-01_channels.json', True), |
| 111 | + ('/sub-01/ses-1/sub-01_ses-1_space-CapTrak_electrodes.tsv', True), |
| 112 | + ('/sub-01/ses-1/sub-01_ses-1_coordsystem.json', True), |
| 113 | + ('/sub-01/sub-01_space-CapTrak_electrodes.tsv', True), |
| 114 | + ('/sub-01/sub-01_coordsystem.json', True), |
| 115 | + ('/sub-01/ses-1/sub-01_ses-1_motion.json', True), |
| 116 | + ('/sub-01/sub-01_motion.json', True), |
| 117 | + ('/sub-01/ses-1/sub-01_ses-1_TEM.json', True), |
| 118 | + ('/sub-01/sub-01_TEM.json', True), |
| 119 | + ('/sub-01/ses-1/sub-01_ses-1_nirs.json', True), |
| 120 | + ('/sub-01/sub-01_nirs.json', True), |
| 121 | + # Mismatch sessions |
| 122 | + ('/sub-01/sub-01_ses-1_scans.tsv', False), |
| 123 | + ('/sub-01/sub-01_ses-1_scans.json', False), |
| 124 | + ('/sub-01/ses-1/sub-01_ses-2_scans.tsv', False), |
| 125 | + # File-level |
| 126 | + ('/sub-01/ses-1/func/sub-01_ses-1_task-rest_bold.nii.gz', False), |
| 127 | + ('/sub-01/anat/sub-01_T1w.nii.gz', False), |
| 128 | + ], |
| 129 | +) |
123 | 130 | def test_session_level(validator, fname, matches):
|
124 | 131 | """Test that is_session_level returns true for session level files."""
|
125 | 132 | assert validator.is_session_level(fname) is matches
|
126 | 133 |
|
127 | 134 |
|
128 |
| -@pytest.mark.parametrize('fname, matches', [ |
129 |
| - ('/sub-01/sub-01_sessions.tsv', True), |
130 |
| - ('/sub-01/sub-01_sessions.json', True), |
131 |
| - ('/sub-01/anat/sub-01_T1w.nii.gz', False), |
132 |
| -]) |
| 135 | +@pytest.mark.parametrize( |
| 136 | + ('fname', 'matches'), |
| 137 | + [ |
| 138 | + ('/sub-01/sub-01_sessions.tsv', True), |
| 139 | + ('/sub-01/sub-01_sessions.json', True), |
| 140 | + ('/sub-01/anat/sub-01_T1w.nii.gz', False), |
| 141 | + ], |
| 142 | +) |
133 | 143 | def test_subject_level(validator, fname, matches):
|
134 | 144 | """Test that is_subject_level returns true for subject level files."""
|
135 | 145 | assert validator.is_subject_level(fname) is matches
|
136 | 146 |
|
137 | 147 |
|
138 |
| -@pytest.mark.parametrize('fname, matches', [ |
139 |
| - ('/phenotype/measure.tsv', True), |
140 |
| - ('/phenotype/measure.json', True), |
141 |
| - ('/sub-01/anat/sub-01_T1w.nii.gz', False), |
142 |
| -]) |
| 148 | +@pytest.mark.parametrize( |
| 149 | + ('fname', 'matches'), |
| 150 | + [ |
| 151 | + ('/phenotype/measure.tsv', True), |
| 152 | + ('/phenotype/measure.json', True), |
| 153 | + ('/sub-01/anat/sub-01_T1w.nii.gz', False), |
| 154 | + ], |
| 155 | +) |
143 | 156 | def test_phenotpic(validator, fname, matches):
|
144 | 157 | """Test that is_phenotypic returns true for phenotypic files."""
|
145 | 158 | assert validator.is_phenotypic(fname) is matches
|
146 | 159 |
|
147 | 160 |
|
148 |
| -@pytest.mark.parametrize('fname, matches', [ |
149 |
| - ('/sub-01/ses-1/func/sub-01_ses-1_task-rest_bold.nii.gz', True), |
150 |
| - ('/sub-01/anat/sub-01_T1w.nii.gz', True), |
151 |
| -]) |
| 161 | +@pytest.mark.parametrize( |
| 162 | + ('fname', 'matches'), |
| 163 | + [ |
| 164 | + ('/sub-01/ses-1/func/sub-01_ses-1_task-rest_bold.nii.gz', True), |
| 165 | + ('/sub-01/anat/sub-01_T1w.nii.gz', True), |
| 166 | + ], |
| 167 | +) |
152 | 168 | def test_file_level(validator, fname, matches):
|
153 | 169 | """Test that is_file returns true for file level files."""
|
154 | 170 | assert validator.is_file(fname) is matches
|
0 commit comments