-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TEST: Check SurfaceDataFile retrieval
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from pathlib import Path | ||
import unittest | ||
|
||
from nibabel.cifti2.caretspec import * | ||
|
||
from nibabel.testing import data_path | ||
from nibabel.optpkg import optional_package | ||
|
||
requests, has_requests, _ = optional_package('requests') | ||
|
||
|
||
def test_CaretSpecFile(): | ||
fsLR = CaretSpecFile.from_filename(Path(data_path) / "fsLR.wb.spec") | ||
|
||
assert fsLR.metadata == {} | ||
assert fsLR.version == "1.0" | ||
assert len(fsLR.data_files) == 5 | ||
|
||
for df in fsLR.data_files: | ||
assert isinstance(df, CaretSpecDataFile) | ||
if df.data_file_type == 'SURFACE': | ||
assert isinstance(df, SurfaceDataFile) | ||
|
||
|
||
@unittest.skipUnless(has_requests, reason="Test fetches from URL") | ||
def test_SurfaceDataFile(): | ||
fsLR = CaretSpecFile.from_filename(Path(data_path) / "fsLR.wb.spec") | ||
df = fsLR.data_files[0] | ||
assert df.data_file_type == 'SURFACE' | ||
try: | ||
coords, triangles = df.get_mesh() | ||
except IOError: | ||
raise unittest.SkipTest(reason="Broken URL") | ||
assert coords.shape == (32492, 3) | ||
assert triangles.shape == (64980, 3) |