MCPcopy Create free account
hub / github.com/CommonstackAI/UncommonRoute / test_hourly_limit

Method test_hourly_limit

tests/test_spend_control.py:42–53  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

40 assert blocked.blocked_by == "session"
41
42 def test_hourly_limit(self) -> None:
43 clock = _FakeClock(1000.0)
44 sc = SpendControl(storage=InMemorySpendControlStorage(), now_fn=clock)
45 sc.set_limit("hourly", 2.00)
46
47 sc.record(1.50, model="model-a")
48 assert sc.check(0.40).allowed is True
49 assert sc.check(0.60).allowed is False
50
51 # Advance 1 hour → window resets
52 clock.advance(3601)
53 assert sc.check(2.00).allowed is True
54
55 def test_daily_limit(self) -> None:
56 clock = _FakeClock(1000.0)

Callers

nothing calls this directly

Calls 7

set_limitMethod · 0.95
recordMethod · 0.95
checkMethod · 0.95
SpendControlClass · 0.90
_FakeClockClass · 0.85
advanceMethod · 0.80

Tested by

no test coverage detected