Massive Improvements & MVP Patches
This commit is contained in:
31
tests/test_main_logging.py
Normal file
31
tests/test_main_logging.py
Normal file
@@ -0,0 +1,31 @@
|
||||
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
|
||||
Reference in New Issue
Block a user