Merge pull request #38 from macaodha/test/add_audio_files_provided_by_padpadpadpad_to_test_suite

test: Add failing audio files from GH-29 to contrib test suite
This commit is contained in:
Santiago Martinez Balvanera 2024-11-11 12:23:03 +00:00 committed by GitHub
commit c5c9476e52
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 40 additions and 7 deletions

Binary file not shown.

Binary file not shown.

View File

@ -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
@ -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():
@ -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):
@ -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:

View File

@ -9,7 +9,7 @@ from batdetect2.cli import cli
runner = CliRunner()
def test_files_negative_dimensions_are_not_allowed(
def test_can_process_jeff37_files(
contrib_dir: Path,
tmp_path: Path,
):
@ -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