def gen_ubatch(number, start_index=1, fields=None, perms=None):
    """
    Utility function to generate an APIUser data batch.

    `number` is the number of users to generate.
    `fields` is the list of fieldnames to generate for each user.
    `perms` is the list of permission names.
    """
    fields = fields or ('username', 'secret_text', 'password', 'email',
                        'first_name', 'last_name')
    pdict = {p: True for p in (perms or ('first', 'second', 'third'))}
    return [
        { f: ('{}{}'.format(f[0:2], i + start_index) if f in fields else pdict)
            for f in fields + ('permissions_dict',) }
                for i in range(0, number)
    ]