26 lines
893 B
Python
26 lines
893 B
Python
import pytest
|
|
|
|
from favorite_stickers.config import Settings
|
|
|
|
|
|
def test_settings_require_bot_token(monkeypatch, tmp_path) -> None:
|
|
monkeypatch.delenv("BOT_TOKEN", raising=False)
|
|
with pytest.raises(ValueError, match="BOT_TOKEN"):
|
|
Settings.from_env()
|
|
|
|
|
|
def test_settings_read_paths_and_limit(monkeypatch, tmp_path) -> None:
|
|
monkeypatch.setenv("BOT_TOKEN", "123:test")
|
|
monkeypatch.setenv("DATABASE_PATH", str(tmp_path / "db.sqlite3"))
|
|
monkeypatch.setenv("MAX_DOWNLOAD_MB", "12")
|
|
monkeypatch.setenv("FFMPEG_TIMEOUT_SECONDS", "15")
|
|
monkeypatch.setenv("MAX_CONVERSIONS", "3")
|
|
|
|
settings = Settings.from_env()
|
|
|
|
assert settings.token == "123:test"
|
|
assert settings.database_path == tmp_path / "db.sqlite3"
|
|
assert settings.max_download_bytes == 12 * 1024 * 1024
|
|
assert settings.ffmpeg_timeout_seconds == 15
|
|
assert settings.max_conversions == 3
|