Buckets:

download
raw
833 Bytes
import pytest
from src.services.feedback_service import FeedbackService, FeedbackPolicy
@pytest.mark.asyncio
async def test_rate_limit_enforced(monkeypatch):
svc = FeedbackService(tenant_id=1, user_id=1, policy=FeedbackPolicy(max_comments_per_day_per_tenant=1))
# First submit should pass (assumes JOB_NOT_FOUND avoided by monkeypatching DB if needed)
async def fake_submit(job_id, goal, final_output, score, comment):
# bypass DB by monkeypatching _check_and_increment_rate_limit only
pass
# We just test the rate limiter key increments explicitly
key = await svc._rate_limit_key()
client = await svc.redis.get_client()
await client.delete(key)
await svc._check_and_increment_rate_limit()
with pytest.raises(ValueError):
await svc._check_and_increment_rate_limit()

Xet Storage Details

Size:
833 Bytes
·
Xet hash:
3125b80499a7c8443517e42ff9cddf2a32bdce5b9b4b70d69045e6b9deae5632

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.