Skip to content

Commit

Permalink
Added a test that replicates the error
Browse files Browse the repository at this point in the history
  • Loading branch information
mbsantiago committed Nov 10, 2024
1 parent 697b5db commit d93d828
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 17 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
42 changes: 42 additions & 0 deletions tests/test_contrib.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d93d828

Please sign in to comment.