Spaces:
No application file
No application file
| """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 | |