File size: 2,676 Bytes
1824ea0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
"""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