style: apply black and isort formatting across entire codebase
- Standardize quote style (single to double quotes) - Reorder and group imports alphabetically - Fix line breaks and indentation for consistency - Apply PEP 8 formatting standards Also updated Makefile to exclude both venv and .venv from code quality checks. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -11,10 +11,11 @@ Tests cover:
|
||||
- Edge cases and concurrency scenarios
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from unittest.mock import Mock, patch
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from collections import deque
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from middleware.rate_limiter import RateLimiter
|
||||
|
||||
@@ -306,8 +307,8 @@ class TestRateLimiterStatistics:
|
||||
# Add requests at different times
|
||||
now = datetime.now(timezone.utc)
|
||||
limiter.clients[client_id].append(now - timedelta(minutes=30)) # Within hour
|
||||
limiter.clients[client_id].append(now - timedelta(hours=2)) # Within day
|
||||
limiter.clients[client_id].append(now - timedelta(hours=12)) # Within day
|
||||
limiter.clients[client_id].append(now - timedelta(hours=2)) # Within day
|
||||
limiter.clients[client_id].append(now - timedelta(hours=12)) # Within day
|
||||
|
||||
stats = limiter.get_client_stats(client_id)
|
||||
|
||||
@@ -411,7 +412,9 @@ class TestRateLimiterEdgeCases:
|
||||
limiter = RateLimiter()
|
||||
client_id = "long_window_client"
|
||||
|
||||
result = limiter.allow_request(client_id, max_requests=10, window_seconds=86400*365)
|
||||
result = limiter.allow_request(
|
||||
client_id, max_requests=10, window_seconds=86400 * 365
|
||||
)
|
||||
|
||||
assert result is True
|
||||
|
||||
@@ -421,10 +424,16 @@ class TestRateLimiterEdgeCases:
|
||||
client_id = "same_client"
|
||||
|
||||
# Allow with one limit
|
||||
assert limiter.allow_request(client_id, max_requests=10, window_seconds=3600) is True
|
||||
assert (
|
||||
limiter.allow_request(client_id, max_requests=10, window_seconds=3600)
|
||||
is True
|
||||
)
|
||||
|
||||
# Check with stricter limit
|
||||
assert limiter.allow_request(client_id, max_requests=1, window_seconds=3600) is False
|
||||
assert (
|
||||
limiter.allow_request(client_id, max_requests=1, window_seconds=3600)
|
||||
is False
|
||||
)
|
||||
|
||||
def test_rate_limiter_unicode_client_id(self):
|
||||
"""Test rate limiter with unicode client ID."""
|
||||
|
||||
Reference in New Issue
Block a user