Private
Public Access
0
0
Files
manual_slop/tests/tier2/phase11_sites34_test.py
T
ed fb7014cd63 refactor(ai_client): migrate cleanup + reset_session cache.delete to helper (Phase 11 sites 3+4)
Sites L432 (cleanup) and L450 (reset_session) had:
    try: _gemini_client.caches.delete(name=_gemini_cache.name)
    except Exception: pass

This is bare 'except: pass' = INTERNAL_SILENT_SWALLOW violation (logging is NOT
a drain; 'pass' is the worst form of silent recovery).

Migration: use existing _delete_gemini_cache_result() helper (added Phase 10).
The helper returns Result[None]; on SDK error logs a warning to comms.
The caller ignores the Result (cleanup is best-effort).

Audit: ai_client SS 11 -> 9.
2026-06-20 13:57:27 -04:00

34 lines
1.3 KiB
Python

"""Phase 11 sites 3+4: cleanup + reset_session cache.delete.
Both have:
try: _gemini_client.caches.delete(name=_gemini_cache.name)
except Exception: pass
Migration: use _delete_gemini_cache_result() (already added in Phase 10).
The helper returns Result[None]; on error it logs a warning and resets
cache state. Caller ignores the Result.
"""
import sys
sys.path.insert(0, ".")
def test_phase11_sites34_cleanup_calls_delete_helper():
"""cleanup() must call _delete_gemini_cache_result, not raw caches.delete."""
import inspect
import src.ai_client
src_text = inspect.getsource(src.ai_client.cleanup)
assert "_delete_gemini_cache_result" in src_text, \
"cleanup() should call _delete_gemini_cache_result helper"
assert "except Exception" not in src_text, \
"cleanup() must NOT have a bare 'except Exception: pass'"
def test_phase11_sites34_reset_session_calls_delete_helper():
"""reset_session() must call _delete_gemini_cache_result, not raw caches.delete."""
import inspect
import src.ai_client
src_text = inspect.getsource(src.ai_client.reset_session)
assert "_delete_gemini_cache_result" in src_text, \
"reset_session() should call _delete_gemini_cache_result helper"
assert "except Exception" not in src_text, \
"reset_session() must NOT have a bare 'except Exception: pass'"