mirror of
https://github.com/macaodha/batdetect2.git
synced 2025-06-29 14:41:58 +02:00
Added a test that replicates the error
This commit is contained in:
parent
697b5dbddb
commit
d93d8284d0
1
.gitignore
vendored
1
.gitignore
vendored
@ -110,5 +110,6 @@ experiments/*
|
||||
!batdetect2_notebook.ipynb
|
||||
!batdetect2/models/*.pth.tar
|
||||
!tests/data/*.wav
|
||||
!tests/data/**/*.wav
|
||||
notebooks/lightning_logs
|
||||
example_data/preprocessed
|
||||
|
17
tests/conftest.py
Normal file
17
tests/conftest.py
Normal file
@ -0,0 +1,17 @@
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def data_dir() -> Path:
|
||||
dir = Path(__file__).parent / "data"
|
||||
assert dir.exists()
|
||||
return dir
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def contrib_dir(data_dir) -> Path:
|
||||
dir = data_dir / "contrib"
|
||||
assert dir.exists()
|
||||
return dir
|
BIN
tests/data/contrib/jeff37/0166_20240531_223911.wav
Executable file
BIN
tests/data/contrib/jeff37/0166_20240531_223911.wav
Executable file
Binary file not shown.
BIN
tests/data/contrib/jeff37/0166_20240602_225340.wav
Executable file
BIN
tests/data/contrib/jeff37/0166_20240602_225340.wav
Executable file
Binary file not shown.
BIN
tests/data/contrib/jeff37/0166_20240603_033731.wav
Executable file
BIN
tests/data/contrib/jeff37/0166_20240603_033731.wav
Executable file
Binary file not shown.
BIN
tests/data/contrib/jeff37/0166_20240603_033937.wav
Executable file
BIN
tests/data/contrib/jeff37/0166_20240603_033937.wav
Executable file
Binary file not shown.
BIN
tests/data/contrib/jeff37/0166_20240604_233500.wav
Executable file
BIN
tests/data/contrib/jeff37/0166_20240604_233500.wav
Executable file
Binary file not shown.
42
tests/test_contrib.py
Normal file
42
tests/test_contrib.py
Normal file
@ -0,0 +1,42 @@
|
||||
"""Test suite to ensure user provided files are correctly processed."""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from click.testing import CliRunner
|
||||
|
||||
from batdetect2.cli import cli
|
||||
|
||||
runner = CliRunner()
|
||||
|
||||
|
||||
def test_files_negative_dimensions_are_not_allowed(
|
||||
contrib_dir: Path,
|
||||
tmp_path: Path,
|
||||
):
|
||||
"""This test stems from issue #31.
|
||||
|
||||
A user provided a set of files which which batdetect2 cli failed and
|
||||
generated the following error message:
|
||||
|
||||
[2272] "Error processing file!: negative dimensions are not allowed"
|
||||
|
||||
This test ensures that the error message is not generated when running
|
||||
batdetect2 cli with the same set of files.
|
||||
"""
|
||||
path = contrib_dir / "jeff37"
|
||||
assert path.exists()
|
||||
|
||||
results_dir = tmp_path / "results"
|
||||
result = runner.invoke(
|
||||
cli,
|
||||
[
|
||||
"detect",
|
||||
str(path),
|
||||
str(results_dir),
|
||||
"0.3",
|
||||
],
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
assert results_dir.exists()
|
||||
assert len(list(results_dir.glob("*.csv"))) == 3
|
||||
assert len(list(results_dir.glob("*.json"))) == 3
|
Loading…
Reference in New Issue
Block a user