Testing Facilities

class x11x_wagtail_blog.fakers.X11XWagtailBlogProvider

Provider for the wonderful faker library. Add X11XWagtailBlogProvider to a standard faker to generate data for your test code.

>>> from faker import Faker
>>> fake = Faker()
>>> fake.add_provider(X11XWagtailBlogProvider)
>>> fake.avatar_image_content()  
b'\x89PNG...
avatar_image_content(*, size=(32, 32))

Generate an avatar image of the given size. By default, the image will be a PNG 32 pixels by 32 pixels.

The use of the image generation functions require the PIL library to be installed.

Parameters:

size (tuple[int, int]) – The width and height of the image to generate.

Return bytes:

Returns the binary content of the PNG.

>>> fake.avatar_image_content(size=(4, 4))  
b'\x89PNG...
avatar_image_file()

Generates a django.core.files.images.ImageFile that can be assigned to a user’s profile.

The use of the image generation functions require the PIL library to be installed.

>>> fake.avatar_image_file()
<ImageFile: ....png>
about_the_author(author)

Generates an AboutTheAuthor snippet.

title_image_content(*, size=(2, 2))

Generates image content suitable for the ‘title_image’. Unless size is given, a 2x2 pixel image will be generated.

>>> fake.title_image_content()  
b'\x89PNG...
Parameters:

size (tuple[int, int]) – The width and height of the image to generate.

Return bytes:

Returns the content of the title image.

title_image_file(*, name=None)

Generates a django.core.files.images.ImageFile that can be assigned to a user’s profile.

>>> fake.title_image_file(name="this-name.png")
<ImageFile: this-name.png>
Parameters:

name (str) – The name of the image file to generate.

Return ImageFile:

Returns an ImageFile