From 4e2d6ab15f7a9b81e211bb0c54b1f5828d693740 Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Mon, 12 Oct 2026 19:01:51 -0700 Subject: [PATCH] test(proxy): give the spend counter test fakes the reset fence hook CountingRedis skipped RedisCache.__init__ and _ExpiringRedisCache never had reset_fence_key, so the repair's broad except swallowed the AttributeError and the counter stayed stale in five tests --- tests/unit/proxy/spend_tracking/test_spend_counter_batch.py | 1 + tests/unit/proxy/test_budget_reservation.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/tests/unit/proxy/spend_tracking/test_spend_counter_batch.py b/tests/unit/proxy/spend_tracking/test_spend_counter_batch.py index bdb430e1945..d7844e58273 100644 --- a/tests/unit/proxy/spend_tracking/test_spend_counter_batch.py +++ b/tests/unit/proxy/spend_tracking/test_spend_counter_batch.py @@ -41,6 +41,7 @@ class CountingRedis(RedisCache): self.store: dict[str, object] = dict(store or {}) self.fail = fail self.commands: list[str] = [] + self.namespace = None async def async_get_cache(self, key: str, **kwargs: object) -> object: if self.fail: diff --git a/tests/unit/proxy/test_budget_reservation.py b/tests/unit/proxy/test_budget_reservation.py index 9fe30f4c696..d62659212d0 100644 --- a/tests/unit/proxy/test_budget_reservation.py +++ b/tests/unit/proxy/test_budget_reservation.py @@ -2366,6 +2366,9 @@ class _ExpiringRedisCache: self.expires_at[key] = self._expiry(kwargs.get("ttl")) return self.store[key] + def reset_fence_key(self, key: str) -> str: + return f"{{{key}}}:reset_fence" + async def async_set_max(self, key: str, value: float, **kwargs: object) -> float: self._evict_expired(key) self.store[key] = max(self.store.get(key, float("-inf")), float(value))