|
1 | 1 | """Test cubids apply.""" |
2 | 2 |
|
| 3 | +import pandas as pd |
3 | 4 | import pytest |
4 | 5 | from niworkflows.utils.testing import generate_bids_skeleton |
5 | 6 |
|
6 | | -relpath_intendedfor = { |
| 7 | +relpath_longitudinal_intendedfor = { |
7 | 8 | '01': [ |
8 | 9 | { |
9 | 10 | 'session': '01', |
|
42 | 43 | ], |
43 | 44 | } |
44 | 45 |
|
45 | | -bidsuri_intendedfor = { |
| 46 | +bidsuri_longitudinal_intendedfor = { |
46 | 47 | '01': [ |
47 | 48 | { |
48 | 49 | 'session': '01', |
|
80 | 81 | }, |
81 | 82 | ], |
82 | 83 | } |
| 84 | + |
| 85 | + |
| 86 | +@pytest.mark.parametrize( |
| 87 | + ('name', 'skeleton', 'expected'), |
| 88 | + [ |
| 89 | + ('relpath_longitudinal', relpath_longitudinal_intendedfor, 'pass'), |
| 90 | + ('bidsuri_longitudinal', bidsuri_longitudinal_intendedfor, 'error'), |
| 91 | + ], |
| 92 | +) |
| 93 | +def test_cubids_apply_intendedfor(tmpdir, name, skeleton, expected): |
| 94 | + """Test cubids apply with different IntendedFor types.""" |
| 95 | + from cubids.workflows import apply |
| 96 | + |
| 97 | + # Generate a BIDS dataset |
| 98 | + bids_dir = str(tmpdir / name) |
| 99 | + generate_bids_skeleton(bids_dir, skeleton) |
| 100 | + |
| 101 | + # Create a summary tsv |
| 102 | + summary_tsv = tmpdir / 'summary.tsv' |
| 103 | + df = pd.DataFrame() |
| 104 | + df.to_csv(summary_tsv, sep='\t', index=False) |
| 105 | + |
| 106 | + # Run cubids apply |
| 107 | + apply(bids_dir, summary_tsv) |
| 108 | + |
| 109 | + # Check the results |
| 110 | + if expected == 'pass': |
| 111 | + # Look at the IntendedFor in the renamed files and it should be correct |
| 112 | + assert True |
| 113 | + elif expected == 'error': |
| 114 | + # Look at the IntendedFor in the renamed files and it should NOT be correct |
| 115 | + assert False |
| 116 | + else: |
| 117 | + raise ValueError(f'Unknown expected value: {expected}') |
0 commit comments