Skip to content

Commit

Permalink
Merge pull request #38 from macaodha/test/add_audio_files_provided_by…
Browse files Browse the repository at this point in the history
…_padpadpadpad_to_test_suite

test: Add failing audio files from GH-29 to contrib test suite
  • Loading branch information
mbsantiago authored Nov 11, 2024
2 parents 4627ddd + 270b3f2 commit c5c9476
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 7 deletions.
Binary file added tests/data/contrib/padpadpadpad/Audiomoth.WAV
Binary file not shown.
Binary file not shown.
Binary file added tests/data/contrib/padpadpadpad/Echometer.wav
Binary file not shown.
14 changes: 8 additions & 6 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
"""Test the command line interface."""

from pathlib import Path
from click.testing import CliRunner

import pandas as pd
from click.testing import CliRunner

from batdetect2.cli import cli

Expand All @@ -11,7 +13,9 @@ def test_cli_base_command():
runner = CliRunner()
result = runner.invoke(cli, ["--help"])
assert result.exit_code == 0
assert "BatDetect2 - Bat Call Detection and Classification" in result.output
assert (
"BatDetect2 - Bat Call Detection and Classification" in result.output
)


def test_cli_detect_command_help():
Expand Down Expand Up @@ -68,8 +72,7 @@ def test_cli_detect_command_with_non_trivial_time_expansion(tmp_path):
)

assert result.exit_code == 0
assert 'Time Expansion Factor: 10' in result.stdout

assert "Time Expansion Factor: 10" in result.stdout


def test_cli_detect_command_with_the_spec_feature_flag(tmp_path: Path):
Expand All @@ -94,13 +97,12 @@ def test_cli_detect_command_with_the_spec_feature_flag(tmp_path: Path):
assert result.exit_code == 0
assert results_dir.exists()


csv_files = [path.name for path in results_dir.glob("*.csv")]

expected_files = [
"20170701_213954-MYOMYS-LR_0_0.5.wav_spec_features.csv",
"20180530_213516-EPTSER-LR_0_0.5.wav_spec_features.csv",
"20180627_215323-RHIFER-LR_0_0.5.wav_spec_features.csv"
"20180627_215323-RHIFER-LR_0_0.5.wav_spec_features.csv",
]

for expected_file in expected_files:
Expand Down
33 changes: 32 additions & 1 deletion tests/test_contrib.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
runner = CliRunner()


def test_files_negative_dimensions_are_not_allowed(
def test_can_process_jeff37_files(
contrib_dir: Path,
tmp_path: Path,
):
Expand Down Expand Up @@ -40,3 +40,34 @@ def test_files_negative_dimensions_are_not_allowed(
assert results_dir.exists()
assert len(list(results_dir.glob("*.csv"))) == 5
assert len(list(results_dir.glob("*.json"))) == 5


def test_can_process_padpadpadpad_files(
contrib_dir: Path,
tmp_path: Path,
):
"""This test stems from issue #29.
Batdetect2 cli failed on the files provided by the user @padpadpadpad
with the following error message:
AttributeError: module 'numpy' has no attribute 'AxisError'
This test ensures that the files are processed without any error.
"""
path = contrib_dir / "padpadpadpad"
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"))) == 2
assert len(list(results_dir.glob("*.json"))) == 2

0 comments on commit c5c9476

Please sign in to comment.