-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_longitudinal.py
More file actions
65 lines (53 loc) · 1.95 KB
/
test_longitudinal.py
File metadata and controls
65 lines (53 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
"""Unit tests for Longitudinal CLI module."""
from __future__ import annotations
import argparse
from typing import TYPE_CHECKING
import pytest
if TYPE_CHECKING:
from pathlib import Path
from rbc.cli.longitudinal import LongitudinalArgs
@pytest.fixture
def base_args(tmp_path: Path) -> argparse.Namespace:
"""Fixture for base argument namespace."""
input_dir = tmp_path / "input"
input_dir.touch()
return argparse.Namespace(
runner="local",
verbose=False,
input_dirs=[input_dir],
output_dir=tmp_path / "output",
participant_label=[],
session_label=[],
anatomical=True,
functional=False,
tmp_dir=None,
anat_template=None,
ants_threads=1,
regressor=["36-parameter"],
)
class TestLongitudinalArgs:
"""Tests for LongitudinalArgs validation."""
@pytest.mark.parametrize(
("anat", "func"), [(True, False), (False, True), (True, True)]
)
def test_valid_flag_combinations(
self,
base_args: argparse.Namespace,
anat: bool, # noqa: FBT001
func: bool, # noqa: FBT001
) -> None:
"""Test different combination of valid longitudinal flags."""
base_args.anatomical, base_args.functional = anat, func
args = LongitudinalArgs.validate_namespace(base_args)
assert args.anatomical is anat
assert args.functional is func
def test_no_flags_raises(self, base_args: argparse.Namespace) -> None:
"""Test error raised if no processing selected."""
base_args.anatomical = base_args.functional = False
with pytest.raises(ValueError, match="At least one of"):
LongitudinalArgs.validate_namespace(base_args)
def test_defaults(self, base_args: argparse.Namespace) -> None:
"""Test defaults."""
args = LongitudinalArgs.validate_namespace(base_args)
assert args.participant_label == []
assert args.session_label == []