| 83 | spend_control.record(-0.01) |
| 84 | |
| 85 | def test_status(self, spend_control: SpendControl) -> None: |
| 86 | spend_control.set_limit("hourly", 5.00) |
| 87 | spend_control.record(1.00, model="model-a") |
| 88 | spend_control.record(0.50, model="model-b") |
| 89 | |
| 90 | s = spend_control.status() |
| 91 | assert s.limits.hourly == 5.00 |
| 92 | assert s.spent["session"] == pytest.approx(1.50) |
| 93 | assert s.remaining["hourly"] == pytest.approx(3.50) |
| 94 | assert s.calls == 2 |
| 95 | |
| 96 | def test_history(self, spend_control: SpendControl) -> None: |
| 97 | spend_control.record(0.10, model="a") |