35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
from pydantic import ValidationError
|
||
|
|
import pytest
|
||
|
|
from pytest import MonkeyPatch
|
||
|
|
|
||
|
|
from core.config.settings import Settings
|
||
|
|
|
||
|
|
|
||
|
|
def test_social_prefixed_storage_env_populates_settings(
|
||
|
|
monkeypatch: MonkeyPatch,
|
||
|
|
) -> None:
|
||
|
|
monkeypatch.setenv("SOCIAL_STORAGE__PROVIDER", "supabase")
|
||
|
|
monkeypatch.setenv("SOCIAL_STORAGE__BUCKET", "agent-chat-attachments")
|
||
|
|
monkeypatch.setenv("SOCIAL_STORAGE__SIGNED_URL_TTL_SECONDS", "900")
|
||
|
|
monkeypatch.setenv("SOCIAL_STORAGE__MAX_FILE_SIZE_MB", "25")
|
||
|
|
monkeypatch.setenv("SOCIAL_STORAGE__RETENTION_DAYS", "45")
|
||
|
|
|
||
|
|
settings = Settings()
|
||
|
|
|
||
|
|
assert settings.storage.provider == "supabase"
|
||
|
|
assert settings.storage.bucket == "agent-chat-attachments"
|
||
|
|
assert settings.storage.signed_url_ttl_seconds == 900
|
||
|
|
assert settings.storage.max_file_size_mb == 25
|
||
|
|
assert settings.storage.retention_days == 45
|
||
|
|
|
||
|
|
|
||
|
|
def test_storage_settings_validation_rejects_invalid_provider(
|
||
|
|
monkeypatch: MonkeyPatch,
|
||
|
|
) -> None:
|
||
|
|
monkeypatch.setenv("SOCIAL_STORAGE__PROVIDER", "s3")
|
||
|
|
|
||
|
|
with pytest.raises(ValidationError):
|
||
|
|
Settings()
|