"""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'"