Massive Improvements & MVP Patches
This commit is contained in:
25
tests/test_main_env_validation.py
Normal file
25
tests/test_main_env_validation.py
Normal file
@@ -0,0 +1,25 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from gitea_codex_bot.config import get_settings
|
||||
from gitea_codex_bot.main import _validate_required_env
|
||||
|
||||
|
||||
def test_validate_required_env_requires_api_key_in_api_key_mode(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
monkeypatch.setenv("OPENAI_API_KEY", "")
|
||||
monkeypatch.setenv("CODEX_AUTH_MODE", "api_key")
|
||||
get_settings.cache_clear()
|
||||
settings = get_settings()
|
||||
|
||||
with pytest.raises(RuntimeError, match="OPENAI_API_KEY is required"):
|
||||
_validate_required_env(settings)
|
||||
|
||||
|
||||
def test_validate_required_env_allows_missing_key_in_chatgpt_mode(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
monkeypatch.setenv("OPENAI_API_KEY", "")
|
||||
monkeypatch.setenv("CODEX_AUTH_MODE", "chatgpt")
|
||||
get_settings.cache_clear()
|
||||
settings = get_settings()
|
||||
|
||||
_validate_required_env(settings)
|
||||
Reference in New Issue
Block a user