Spaces:
No application file
No application file
File size: 1,824 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 | """Tests for configuration loading."""
import pytest
from stemsplitter.config import Settings, get_settings
class TestSettings:
def test_defaults(self):
"""Settings should provide sensible defaults."""
s = Settings()
assert s.output_format in ("WAV", "MP3", "FLAC")
assert s.sample_rate == 44100
assert s.normalization == 0.9
assert s.web_port == 7860
assert s.log_level == "WARNING"
def test_env_override(self, monkeypatch):
"""Settings should pick up environment variable overrides."""
monkeypatch.setenv("STEMSPLITTER_OUTPUT_FORMAT", "FLAC")
monkeypatch.setenv("STEMSPLITTER_SAMPLE_RATE", "48000")
monkeypatch.setenv("STEMSPLITTER_WEB_PORT", "9090")
s = get_settings()
assert s.output_format == "FLAC"
assert s.sample_rate == 48000
assert s.web_port == 9090
def test_immutability(self):
"""Settings instances should be frozen."""
s = Settings()
with pytest.raises(AttributeError):
s.output_dir = "/some/other/path" # type: ignore
def test_output_dir_default(self):
"""Default output_dir should be ./output."""
s = Settings()
assert s.output_dir == "./output"
def test_model_defaults(self):
"""Default models should be set for both modes."""
s = Settings()
assert "mel_band_roformer" in s.default_2stem_model
assert "htdemucs_ft" in s.default_4stem_model
def test_get_settings_returns_fresh_instance(self, monkeypatch):
"""get_settings should create a new instance each time."""
s1 = get_settings()
monkeypatch.setenv("STEMSPLITTER_OUTPUT_FORMAT", "MP3")
s2 = get_settings()
assert s2.output_format == "MP3"
assert s1 is not s2
|