Files
gitea-codex/tests/test_main_logging.py
Space-Banane 7b63ecd536
All checks were successful
ci / test (push) Successful in 27s
ci / publish (push) Successful in 1m24s
Massive Improvements & MVP Patches
2026-05-22 21:27:48 +02:00

32 lines
1.1 KiB
Python

from __future__ import annotations
import logging
from gitea_codex_bot.config import get_settings
from gitea_codex_bot.main import _log_startup_auth_json_status, _log_startup_identity
def test_log_startup_identity_includes_bot_username(caplog) -> None:
settings = get_settings()
caplog.set_level(logging.INFO, logger="gitea_codex_bot.main")
_log_startup_identity(settings)
assert "Bot startup identity:" in caplog.text
assert "username=codex-bot" in caplog.text
def test_log_startup_auth_json_valid_when_configured(monkeypatch, tmp_path, caplog) -> None:
auth_file = tmp_path / "auth.json"
auth_file.write_text('{"auth_mode":"chatgpt"}', encoding="utf-8")
monkeypatch.setenv("CODEX_AUTH_MODE", "chatgpt")
monkeypatch.setenv("CODEX_AUTH_JSON_PATH", str(auth_file))
get_settings.cache_clear()
settings = get_settings()
caplog.set_level(logging.INFO, logger="gitea_codex_bot.main")
_log_startup_auth_json_status(settings)
assert "mode=chatgpt auth.json valid" in caplog.text
assert str(auth_file) in caplog.text