-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
- Loading branch information
1 parent
db9d5a1
commit 69518bd
Showing
1 changed file
with
29 additions
and
14 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,36 +1,51 @@ | ||
from brainreg.core.cli import prep_registration | ||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
from brainreg.core.cli import prep_registration | ||
|
||
|
||
def test_prep_registration_different_names(mocker): | ||
"""Check that additional channel names are returned, when unique.""" | ||
args = mocker.Mock() | ||
args.brainreg_directory=Path.home() # This just needs to exist | ||
args.additional_images=[Path.home()/"additional_channel_0", Path.home()/"additional_channel_1"] | ||
|
||
args.brainreg_directory = Path.home() # This just needs to exist | ||
args.additional_images = [ | ||
Path.home() / "additional_channel_0", | ||
Path.home() / "additional_channel_1", | ||
] | ||
|
||
_, additional_channel_outputs = prep_registration(args) | ||
assert "additional_channel_0" in additional_channel_outputs | ||
assert "additional_channel_1" in additional_channel_outputs | ||
|
||
|
||
def test_additional_channels_same_name_different_parent_name(mocker): | ||
""" | ||
Check that parent folder name returned if additional channel names are not unique. | ||
""" | ||
args = mocker.Mock() | ||
args.brainreg_directory=Path.home() # This just needs to exist | ||
args.additional_images=[Path.home()/"folder_0/duplicate_name", Path.home()/"folder_1/duplicate_name"] | ||
|
||
args.brainreg_directory = Path.home() # This just needs to exist | ||
args.additional_images = [ | ||
Path.home() / "folder_0/duplicate_name", | ||
Path.home() / "folder_1/duplicate_name", | ||
] | ||
|
||
_, additional_channel_outputs = prep_registration(args) | ||
assert "folder_1_duplicate_name" in additional_channel_outputs | ||
assert "folder_1_duplicate_name" in additional_channel_outputs | ||
|
||
|
||
def test_prep_registration_same_name_same_parent_name(mocker): | ||
"""Check that error is thrown if both parent and additional channel name are non-unique.""" | ||
args = mocker.Mock() | ||
args.brainreg_directory=Path.home() # This just needs to exist | ||
args.additional_images=[str(Path.home()/"duplicate_name"), str(Path.home()/"duplicate_name")] | ||
|
||
with pytest.raises(AssertionError, match=".*ensure additional channels have a unique combination of name and parent folder.*"): | ||
prep_registration(args) | ||
args.brainreg_directory = Path.home() # This just needs to exist | ||
args.additional_images = [ | ||
str(Path.home() / "duplicate_name"), | ||
str(Path.home() / "duplicate_name"), | ||
] | ||
|
||
with pytest.raises( | ||
AssertionError, | ||
match=".*ensure additional channels have a unique combination of name and parent folder.*", | ||
): | ||
prep_registration(args) |