-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add unit tests for anat pipeline (might change to more general later...)
- Loading branch information
1 parent
124a61f
commit 2fb77c9
Showing
1 changed file
with
68 additions
and
0 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
test/unittests/pipelines/t1_linear/test_anat_linear_pipeline.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import re | ||
|
||
import pytest | ||
|
||
|
||
def test_anat_linear_pipeline_no_input_error(tmp_path): | ||
from clinica.pipelines.t1_linear.anat_linear_pipeline import AnatLinear | ||
|
||
with pytest.raises( | ||
RuntimeError, | ||
match=( | ||
"The AnatLinear pipeline does not contain BIDS " | ||
"nor CAPS directory at the initialization." | ||
), | ||
): | ||
AnatLinear() | ||
|
||
|
||
def test_anat_linear_pipeline_single_bids_input_error(tmp_path): | ||
from clinica.pipelines.t1_linear.anat_linear_pipeline import AnatLinear | ||
from clinica.utils.exceptions import ClinicaBIDSError | ||
|
||
with pytest.raises( | ||
ClinicaBIDSError, | ||
match=re.escape( | ||
f"The BIDS directory ({tmp_path}) you provided " | ||
"is missing a dataset_description.json file." | ||
), | ||
): | ||
AnatLinear(bids_directory=str(tmp_path)) | ||
|
||
|
||
def test_anat_linear_pipeline_single_caps_input_error(tmp_path): | ||
from clinica.pipelines.t1_linear.anat_linear_pipeline import AnatLinear | ||
from clinica.utils.exceptions import ClinicaCAPSError | ||
|
||
with pytest.raises( | ||
ClinicaCAPSError, | ||
match=re.escape( | ||
f"The CAPS directory ({tmp_path}) you provided " | ||
"is missing a dataset_description.json file." | ||
), | ||
): | ||
AnatLinear(caps_directory=str(tmp_path)) | ||
|
||
|
||
def test_anat_linear_pipeline_write_caps_dataset_description(tmp_path): | ||
from clinica.pipelines.t1_linear.anat_linear_pipeline import AnatLinear | ||
from clinica.utils.caps import CAPSDatasetDescription, DatasetType | ||
|
||
bids = tmp_path / "bids" | ||
caps = tmp_path / "caps" | ||
bids.mkdir() | ||
caps.mkdir() | ||
(bids / "dataset_description.json").touch() | ||
(bids / "sub-01").mkdir() | ||
|
||
AnatLinear(bids_directory=str(bids), caps_directory=str(caps)) | ||
|
||
files = [f for f in caps.iterdir()] | ||
assert len(files) == 1 | ||
|
||
desc = CAPSDatasetDescription.from_file(caps / "dataset_description.json") | ||
|
||
assert desc.name == "AnatLinear" | ||
assert desc.bids_version == "1.7.0" | ||
assert desc.caps_version == "1.0.0" | ||
assert desc.dataset_type == DatasetType.DERIVATIVE |