DealDocumentScreening/tests/unit/test_bot_rate_limiter.py

18 lines
697 B
Python

"""Tests for the bot-specific rate limiter factory."""
from __future__ import annotations
from contract_check.bot.rate_limit import get_rate_limiter
from contract_check.core.rate_limit import MemoryRateLimiter
async def test_get_rate_limiter_empty_url_uses_memory() -> None:
limiter = await get_rate_limiter("")
assert isinstance(limiter, MemoryRateLimiter)
async def test_get_rate_limiter_invalid_url_falls_back_to_memory() -> None:
# An unparseable/malformed URL should not crash the bot; it should fall
# back to the in-memory backend so the adapter stays up.
limiter = await get_rate_limiter("not-a-valid-redis-url")
assert isinstance(limiter, MemoryRateLimiter)