Files
gitea-codex/tests/test_config.py
Luna 9028d5b56c
All checks were successful
ci / test (pull_request) Successful in 27s
ci / publish (pull_request) Has been skipped
Harden stuck-job retry accounting and retry config validation
2026-05-22 21:54:56 +00:00

34 lines
1.1 KiB
Python

import pytest
from pydantic import ValidationError
from gitea_codex_bot.config import get_settings
def test_openai_api_key_from_env() -> None:
settings = get_settings()
assert settings.openai_api_key is not None
assert settings.openai_api_key.get_secret_value() == "openai-key"
def test_codex_auth_defaults_to_api_key_mode() -> None:
settings = get_settings()
assert settings.codex_auth_mode == "api_key"
assert settings.codex_auth_json_path is None
def test_job_lease_timeout_must_cover_max_review_runtime(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setenv("MAX_REVIEW_MINUTES", "10")
monkeypatch.setenv("JOB_LEASE_TIMEOUT_SECONDS", "300")
get_settings.cache_clear()
with pytest.raises(ValidationError, match="JOB_LEASE_TIMEOUT_SECONDS must be at least"):
get_settings()
def test_max_stuck_job_retries_must_be_non_negative(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setenv("MAX_STUCK_JOB_RETRIES", "-1")
get_settings.cache_clear()
with pytest.raises(ValidationError, match="MAX_STUCK_JOB_RETRIES must be >= 0"):
get_settings()