Files
hermes-agent/tests/gateway/test_sticker_cache.py
teknium1 982165203d test: purge low-value tests, lane py09 (263 removed)
Change-detectors, tautologies, source-reading tests, redundant duplicates,
mock-echo tests and dead/unrunnable tests. Per-test rationale in the lane
ledger (category + reason for every removal).
2026-09-23 03:15:26 -07:00

48 lines
1.4 KiB
Python

"""Tests for gateway/sticker_cache.py — sticker description cache."""
from unittest.mock import patch
from gateway.sticker_cache import (
_load_cache,
get_cached_description,
cache_sticker_description,
build_sticker_injection,
)
class TestLoadSaveCache:
def test_load_corrupt_file(self, tmp_path):
bad_file = tmp_path / "bad.json"
bad_file.write_text("not json{{{")
with patch("gateway.sticker_cache.CACHE_PATH", bad_file):
assert _load_cache() == {}
class TestCacheSticker:
def test_cache_and_retrieve(self, tmp_path):
cache_file = tmp_path / "cache.json"
with patch("gateway.sticker_cache.CACHE_PATH", cache_file):
cache_sticker_description("uid_1", "A happy dog", emoji="🐕", set_name="Dogs")
result = get_cached_description("uid_1")
assert result is not None
assert result["description"] == "A happy dog"
assert result["emoji"] == "🐕"
assert result["set_name"] == "Dogs"
assert "cached_at" in result
class TestBuildStickerInjection:
def test_set_name_without_emoji_ignored(self):
"""set_name alone (no emoji) produces no context — only emoji+set_name triggers 'from' clause."""
result = build_sticker_injection("A cat", set_name="MyPack")
assert "A cat" in result
assert "MyPack" not in result