"""GZipMiddleware's compresslevel: it runs synchronously on the event loop, so a
lower level (6, the standard speed/ratio sweet spot) trades a little ratio for
noticeably less per-request CPU competing with every other async route."""
from starlette.middleware.gzip import GZipMiddleware

from web import app as appmod


def test_gzip_middleware_uses_a_lowered_compresslevel():
    mw = next(m for m in appmod.app.user_middleware if m.cls is GZipMiddleware)
    assert mw.kwargs.get("compresslevel") == 6
    assert mw.kwargs.get("compresslevel") != 9   # not Starlette's CPU-heavy default
