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

Method test_daily_limit

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

Source from the content-addressed store, hash-verified

53 assert sc.check(2.00).allowed is True
54
55 def test_daily_limit(self) -> None:
56 clock = _FakeClock(1000.0)
57 sc = SpendControl(storage=InMemorySpendControlStorage(), now_fn=clock)
58 sc.set_limit("daily", 10.00)
59
60 sc.record(9.50)
61 assert sc.check(0.40).allowed is True
62 assert sc.check(0.60).allowed is False
63
64 # Advance 24h
65 clock.advance(86401)
66 assert sc.check(10.00).allowed is True
67
68 def test_clear_limit(self, spend_control: SpendControl) -> None:
69 spend_control.set_limit("per_request", 0.01)

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