Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions tests/unit/rate_limiter_window_invariants_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import pytest
import time

def test_sliding_window_burst_clamping():
max_burst = 20
window_seconds = 60
incoming_requests = 25
admitted = min(incoming_requests, max_burst)

assert admitted == 20
assert incoming_requests - admitted == 5

def test_cooldown_expiry_invariants():
cooldown_seconds = 10
start_time = 100
current_time = 112

assert (current_time - start_time) >= cooldown_seconds