40 lines
1.5 KiB
Python
40 lines
1.5 KiB
Python
|
|
import pytest
|
||
|
|
from agent.config import Settings
|
||
|
|
|
||
|
|
|
||
|
|
@pytest.fixture
|
||
|
|
def test_settings(monkeypatch):
|
||
|
|
"""테스트용 환경변수로 Settings 인스턴스 생성"""
|
||
|
|
monkeypatch.setenv("ANTHROPIC_API_KEY", "test-key")
|
||
|
|
monkeypatch.setenv("GITEA_TOKEN", "test-token")
|
||
|
|
monkeypatch.setenv("GITEA_WEBHOOK_SECRET", "test-secret")
|
||
|
|
monkeypatch.setenv("DISCORD_TOKEN", "test-token")
|
||
|
|
monkeypatch.setenv("FERNET_KEY", "dGVzdGtleXRlc3RrZXl0ZXN0a2V5dGVzdGtleXg=")
|
||
|
|
return Settings()
|
||
|
|
|
||
|
|
|
||
|
|
def test_config_loads_defaults(test_settings):
|
||
|
|
assert test_settings.GITEA_URL == "http://gitea:3000"
|
||
|
|
assert test_settings.AUTONOMY_LEVEL == "conservative"
|
||
|
|
assert test_settings.SANDBOX_TIMEOUT == 600
|
||
|
|
assert test_settings.DEFAULT_REPO_OWNER == "quant"
|
||
|
|
assert test_settings.DEFAULT_REPO_NAME == "galaxis-po"
|
||
|
|
assert test_settings.SANDBOX_MEM_LIMIT == "4g"
|
||
|
|
assert test_settings.SANDBOX_CPU_COUNT == 2
|
||
|
|
|
||
|
|
|
||
|
|
def test_config_autonomy_levels(test_settings):
|
||
|
|
assert test_settings.AUTONOMY_LEVEL in ("conservative", "autonomous")
|
||
|
|
|
||
|
|
|
||
|
|
def test_writable_paths_include_backend(test_settings):
|
||
|
|
assert "backend/app/" in test_settings.WRITABLE_PATHS
|
||
|
|
assert "backend/tests/" in test_settings.WRITABLE_PATHS
|
||
|
|
assert "backend/alembic/versions/" in test_settings.WRITABLE_PATHS
|
||
|
|
|
||
|
|
|
||
|
|
def test_blocked_paths_include_protected_files(test_settings):
|
||
|
|
assert ".env" in test_settings.BLOCKED_PATHS
|
||
|
|
assert "quant.md" in test_settings.BLOCKED_PATHS
|
||
|
|
assert "docker-compose.prod.yml" in test_settings.BLOCKED_PATHS
|