-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
145 additions
and
67 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from __future__ import annotations | ||
|
||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
|
||
def data_dir() -> Path: | ||
return Path(__file__).parent / "data" | ||
|
||
|
||
def asc_test_files(input_dir: Path = data_dir()) -> list[Path]: | ||
return list(input_dir.glob("**/*.asc")) | ||
|
||
|
||
def edf_test_files(input_dir: Path = data_dir()) -> list[Path]: | ||
files = list(input_dir.glob("**/*.edf")) | ||
EDF_files = list(input_dir.glob("**/*.EDF")) | ||
files.extend(EDF_files) | ||
return files | ||
|
||
|
||
@pytest.fixture | ||
def eyelink_test_data_dir() -> Path: | ||
return data_dir() / "osf" / "eyelink" |
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,44 @@ | ||
from __future__ import annotations | ||
|
||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
from eye2bids._cli import cli | ||
from eye2bids.edf2bids import _check_edf2asc_present | ||
|
||
from .conftest import data_dir, edf_test_files | ||
|
||
|
||
def root_dir() -> Path: | ||
"""Return the root directory of the project.""" | ||
return Path(__file__).parent.parent | ||
|
||
|
||
@pytest.mark.parametrize("metadata_file", [data_dir() / "metadata.yml", None]) | ||
@pytest.mark.parametrize("output_dir", [data_dir() / "output", None]) | ||
@pytest.mark.parametrize("use_relative_path", [False, True]) | ||
def test_edf_cli(use_relative_path, metadata_file, output_dir, eyelink_test_data_dir): | ||
if not _check_edf2asc_present(): | ||
pytest.skip("edf2asc missing") | ||
|
||
input_dir = eyelink_test_data_dir / "decisions" | ||
input_file = edf_test_files(input_dir=input_dir)[0] | ||
|
||
if use_relative_path: | ||
input_file = input_file.relative_to(root_dir()) | ||
|
||
command = ["eye2bids", "--input_file", str(input_file)] | ||
if metadata_file is not None: | ||
if use_relative_path: | ||
metadata_file = metadata_file.relative_to(root_dir()) | ||
metadata_file = str(metadata_file) | ||
command.extend(["--metadata_file", metadata_file]) | ||
|
||
if output_dir is not None: | ||
if use_relative_path: | ||
output_dir = output_dir.relative_to(root_dir()) | ||
output_dir = str(output_dir) | ||
command.extend(["--output_dir", output_dir]) | ||
|
||
cli(command) |
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