Skip to content

Commit 23c4dea

Browse files
committed
Keep working.
1 parent 8f2a0a1 commit 23c4dea

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

cubids/tests/test_apply.py

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
"""Test cubids apply."""
22

3+
import pandas as pd
34
import pytest
45
from niworkflows.utils.testing import generate_bids_skeleton
56

6-
relpath_intendedfor = {
7+
relpath_longitudinal_intendedfor = {
78
'01': [
89
{
910
'session': '01',
@@ -42,7 +43,7 @@
4243
],
4344
}
4445

45-
bidsuri_intendedfor = {
46+
bidsuri_longitudinal_intendedfor = {
4647
'01': [
4748
{
4849
'session': '01',
@@ -80,3 +81,37 @@
8081
},
8182
],
8283
}
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

Comments
 (0)