Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Atlas version control - first draft (#44)
* Atlas version control - first draft * Interaction with atlas version conf file in GIN * Added some tests
- Loading branch information
Showing
10 changed files
with
131 additions
and
46 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
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
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
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
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
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
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
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,30 @@ | ||
import pytest | ||
import tempfile | ||
import shutil | ||
from brainatlas_api.bg_atlas import ExampleAtlas | ||
|
||
|
||
def test_versions(atlas): | ||
assert atlas.local_version == atlas.remote_version | ||
|
||
|
||
def test_local_search(): | ||
brainglobe_dir = tempfile.mkdtemp() | ||
interm_download_dir = tempfile.mkdtemp() | ||
|
||
atlas = ExampleAtlas( | ||
brainglobe_dir=brainglobe_dir, interm_download_dir=interm_download_dir | ||
) | ||
|
||
assert atlas.atlas_name in atlas.local_full_name | ||
|
||
# Make a copy: | ||
copy_filename = atlas.root_dir.parent / (atlas.root_dir.name + "_2") | ||
shutil.copytree(atlas.root_dir, copy_filename) | ||
|
||
with pytest.raises(FileExistsError) as error: | ||
_ = ExampleAtlas(brainglobe_dir=brainglobe_dir) | ||
assert "Multiple versions of atlas" in str(error) | ||
|
||
shutil.rmtree(brainglobe_dir) | ||
shutil.rmtree(interm_download_dir) |
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
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,15 +1,17 @@ | ||
import brainatlas_api | ||
import pytest | ||
|
||
|
||
def test_list_atlases(): | ||
brainatlas_api.list_atlases() | ||
|
||
|
||
def test_get_atlas_from_name(): | ||
a1 = brainatlas_api.get_atlas_class_from_name("allen_mouse_25um_v0.2") | ||
a2 = brainatlas_api.get_atlas_class_from_name("xxxx") | ||
|
||
if a1 is None: | ||
raise ValueError | ||
if a2 is not None: | ||
raise ValueError | ||
@pytest.mark.parametrize( | ||
"key, is_none", [("allen_mouse_25um", False), ("xxx", True)] | ||
) | ||
def test_get_atlas_from_name(key, is_none): | ||
a = brainatlas_api.get_atlas_class_from_name(key) | ||
if is_none: | ||
assert a is None | ||
else: | ||
assert a is not None |