Skip to main content

Factory boy classes for wagtail

Project description

Factory boy classes for Wagtail CMS

Installation

pip install wagtail-factories

Usage

Documentation is still in progress, but see the tests for more examples.

import wagtail_factories
from . import models


class MyCarouselItemFactory(wagtail_factories.StructBlockFactory):
    label = 'my-label'
    image = factory.SubFactory(
        wagtail_factories.ImageChooserBlockFactory)

    class Meta:
        model = models.MyBlockItem


class MyCarouselFactory(wagtail_factories.StructBlockFactory):
    title = "Carousel title"
    items = wagtail_factories.ListBlockFactory(
        MyCarouselItemFactory)

    class Meta:
        model = models.MyCarousel


class MyTestPageFactory(wagtail_factories.PageFactory):

    body = wagtail_factories.StreamFieldFactory({
        'carousel': MyCarouselFactory
    })

    class Meta:
        model = models.MyTestPage


def test_my_page():
    root_page = wagtail_factories.PageFactory(parent=None)
    my_page = MyTestPageFactory(
        parent=root_page,
        body__0__carousel__items__0__label='Slide 1',
        body__0__carousel__items__0__image__image__title='Image Slide 1',
        body__0__carousel__items__1__label='Slide 2',
        body__0__carousel__items__1__image__image__title='Image Slide 2',
        body__0__carousel__items__2__label='Slide 3',
        body__0__carousel__items__2__image__image__title='Image Slide 3')

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wagtail_factories-2.1.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

wagtail_factories-2.1.0-py2.py3-none-any.whl (5.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file wagtail_factories-2.1.0.tar.gz.

File metadata

  • Download URL: wagtail_factories-2.1.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 CPython/3.10.5

File hashes

Hashes for wagtail_factories-2.1.0.tar.gz
Algorithm Hash digest
SHA256 162cce8f3f7d26aebf19f233e243a24946be74bb281822889ec7f936ba42dbff
MD5 f2ac9f81090451c8e2b07a35d5bf5ade
BLAKE2b-256 d8d5aa517a1c335325f36243457c347e747f2f61a00a9912f9d6e64c2d8f4f58

See more details on using hashes here.

Provenance

File details

Details for the file wagtail_factories-2.1.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for wagtail_factories-2.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 bca1538d2c7faad9a9d024c047c7f695e2753d218ea79b78e410bec77913bee3
MD5 6a8473ec3e0cfa859c13160368da32b2
BLAKE2b-256 ba21ea01885b5393e19f8642c993a67e82f0f6e5240fc6e9c3f0fa91e6a3f51e

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page