rate_limiter.py has 17 tests but none call enforce_rate_limit() itself, only its building blocks (check_cooldown, check_daily_cap, etc.). This
function had a real ordering bug fixed in an earlier audit, it deserves direct coverage.
Untested:
- rate_limit.enabled=False → returns immediately
- force=True → bypasses both checks
- Cooldown active → sys.exit(1)
- Daily cap reached → sys.exit(1)
- Both checks pass → returns normally
Use pytest.raises(SystemExit) for the exit paths. Monkeypatch rate_limiter.USAGE_PATH to a tmp_path file (see existing tests in the same file for the pattern).
rate_limiter.py has 17 tests but none call enforce_rate_limit() itself, only its building blocks (check_cooldown, check_daily_cap, etc.). This
function had a real ordering bug fixed in an earlier audit, it deserves direct coverage.
Untested:
Use pytest.raises(SystemExit) for the exit paths. Monkeypatch rate_limiter.USAGE_PATH to a tmp_path file (see existing tests in the same file for the pattern).