import pytest

from app.services.pdf import PdfGenerationBusy, PdfGenerationLimiter


def test_pdf_generation_limiter_times_out_when_full():
    limiter = PdfGenerationLimiter()
    limiter.acquire(limit=1)
    with pytest.raises(PdfGenerationBusy):
        limiter.acquire(limit=1, timeout_seconds=0)
    limiter.release()
    limiter.acquire(limit=1, timeout_seconds=0)
    limiter.release()
