fix: load credentials from HERMES_HOME .env in trajectory_compressor

This commit is contained in:
Dusk1e 2026-04-14 14:49:57 +03:00 committed by Teknium
parent 8a002d4efc
commit 4b47856f90
2 changed files with 24 additions and 4 deletions

View file

@ -1,6 +1,9 @@
"""Tests for trajectory_compressor.py — config, metrics, and compression logic."""
import importlib
import json
import os
import sys
from types import SimpleNamespace
from unittest.mock import AsyncMock, patch, MagicMock
@ -14,6 +17,20 @@ from trajectory_compressor import (
)
def test_import_loads_env_from_hermes_home(tmp_path, monkeypatch):
home = tmp_path / ".hermes"
home.mkdir()
(home / ".env").write_text("OPENROUTER_API_KEY=from-hermes-home\n", encoding="utf-8")
monkeypatch.setenv("HERMES_HOME", str(home))
monkeypatch.delenv("OPENROUTER_API_KEY", raising=False)
sys.modules.pop("trajectory_compressor", None)
importlib.import_module("trajectory_compressor")
assert os.getenv("OPENROUTER_API_KEY") == "from-hermes-home"
# ---------------------------------------------------------------------------
# CompressionConfig
# ---------------------------------------------------------------------------