import math
import logging
from typing import Collection


def many_collections(mixer, user, app, request):
    """Create a number of collections numbering around the page size for the
    fixture user."""
    n_collections = int(math.ceil(request.param * app.config['PAGE_SIZE']))
    assert n_collections >= 0
    logging.info('Creating %s collection(s) for user', n_collections)

    cs = mixer.cycle(n_collections).blend(Collection, name=mixer.FAKE)
    for c in cs:
        c.add_all_permissions(user)

    return cs