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.0.1.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

wagtail_factories-2.0.1-py2.py3-none-any.whl (5.8 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: wagtail_factories-2.0.1.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.6

File hashes

Hashes for wagtail_factories-2.0.1.tar.gz
Algorithm Hash digest
SHA256 3eeb55199f2c9ffbfe14979a94766d724c9e9f4d8f561df61097884e63bd537f
MD5 e7ef2b8a2f0d2b51b325524cd0d89fa0
BLAKE2b-256 fdd38cd00050726f84828e51402595339f2c5dc3fe3703a6666f97ab0bfcdf33

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: wagtail_factories-2.0.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.6

File hashes

Hashes for wagtail_factories-2.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 e2bd1a22e67b70e1603fc292e97f6f998ee0169477e1f71b5c53368630f1d088
MD5 4f7de469cc3f868652a1b05cccb20be7
BLAKE2b-256 9c0607382b3ca65e1f87211ad1e39edd92843c18c7da3f4675d6f4a20688919b

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