Skip to content

Add tests for enforce_rate_limit() #6

Description

@SemTiOne

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions