StemSplitter / tests /test_cli.py
ymcnabb's picture
Upload folder using huggingface_hub
1824ea0 verified
"""Tests for the CLI interface."""
from click.testing import CliRunner
from stemsplitter.cli import main
class TestCLI:
def test_help(self):
"""--help should succeed and show usage."""
runner = CliRunner()
result = runner.invoke(main, ["--help"])
assert result.exit_code == 0
assert "Separate audio stems" in result.output
def test_missing_file(self):
"""Non-existent file should produce error."""
runner = CliRunner()
result = runner.invoke(main, ["/nonexistent.wav"])
assert result.exit_code != 0
def test_2stem_default(self, mock_separator, test_audio_path, env_settings):
"""Default invocation should use 2-stem mode."""
runner = CliRunner()
result = runner.invoke(main, [str(test_audio_path)])
assert result.exit_code == 0
assert "Separation complete" in result.output
def test_4stem_flac(
self, mock_separator_4stem, test_audio_path, env_settings
):
"""4-stem + FLAC flags should be accepted."""
runner = CliRunner()
result = runner.invoke(
main,
[str(test_audio_path), "-m", "4stem", "-f", "FLAC"],
)
assert result.exit_code == 0
assert "Separation complete" in result.output
def test_custom_output_dir(
self, mock_separator, test_audio_path, tmp_path, env_settings
):
"""--output-dir flag should override the default."""
custom_dir = tmp_path / "custom_out"
runner = CliRunner()
result = runner.invoke(
main,
[str(test_audio_path), "-o", str(custom_dir)],
)
assert result.exit_code == 0
assert custom_dir.is_dir()
def test_output_lists_files(
self, mock_separator, test_audio_path, env_settings
):
"""Output should list the generated stem files."""
runner = CliRunner()
result = runner.invoke(main, [str(test_audio_path)])
assert "->" in result.output
def test_mode_shown_in_output(
self, mock_separator, test_audio_path, env_settings
):
"""The mode should be shown in processing output."""
runner = CliRunner()
result = runner.invoke(main, [str(test_audio_path), "-m", "2stem"])
assert "2stem" in result.output
def test_mp3_format(self, mock_separator, test_audio_path, env_settings):
"""MP3 format flag should be accepted."""
runner = CliRunner()
result = runner.invoke(
main,
[str(test_audio_path), "-f", "MP3"],
)
assert result.exit_code == 0
assert "MP3" in result.output