|
1 | 1 | # TODO: break this up by modules
|
2 | 2 |
|
3 | 3 | from heudiconv.cli.run import main as runner
|
4 |
| -from heudiconv.main import workflow |
| 4 | +from heudiconv.main import (workflow, |
| 5 | + process_extra_commands) |
5 | 6 | from heudiconv import __version__
|
6 | 7 | from heudiconv.utils import (create_file_if_missing,
|
7 | 8 | set_readonly,
|
@@ -290,3 +291,33 @@ def test_no_etelemetry():
|
290 | 291 | with patch.dict('sys.modules', {'etelemetry': None}):
|
291 | 292 | workflow(outdir='/dev/null', command='ls',
|
292 | 293 | heuristic='reproin', files=[])
|
| 294 | + |
| 295 | + |
| 296 | +# Test two scenarios: |
| 297 | +# -study without sessions |
| 298 | +# -study with sessions |
| 299 | +# The "expected_folder" is the session folder without the tmpdir |
| 300 | +@pytest.mark.parametrize( |
| 301 | + "session, expected_folder", [ |
| 302 | + ('', '/foo/sub-{sID}'), |
| 303 | + ('pre', '/foo/sub-{sID}/ses-pre') |
| 304 | + ] |
| 305 | +) |
| 306 | +def test_populate_intended_for(session, expected_folder, capfd): |
| 307 | + """ |
| 308 | + Tests for "process_extra_commands" when the command is |
| 309 | + 'populate_intended_for' |
| 310 | + """ |
| 311 | + # Because the function .utils.populate_intended_for already has its own |
| 312 | + # tests, here we just test that "process_extra_commands", when 'command' |
| 313 | + # is 'populate_intended_for' does what we expect (loop through the list of |
| 314 | + # subjects and calls 'populate_intended_for'). We call it using folders |
| 315 | + # that don't exist, and check that the output is the expected. |
| 316 | + bids_folder = expected_folder.split('sub-')[0] |
| 317 | + subjects = ['1', '2'] |
| 318 | + process_extra_commands(bids_folder, 'populate_intended_for', [], '', |
| 319 | + '', session, subjects, None) |
| 320 | + captured_output = capfd.readouterr().err |
| 321 | + for s in subjects: |
| 322 | + expected_info = 'Adding "IntendedFor" to the fieldmaps in ' + expected_folder.format(sID=s) |
| 323 | + assert expected_info in captured_output |
0 commit comments