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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file wagtail_factories-2.0.0.tar.gz
.
File metadata
- Download URL: wagtail_factories-2.0.0.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 416196b88dcdb2d2787926692d7eef7fa0664556900eb6166537026b085d9fbf |
|
MD5 | f51b2a14c1f521e79e0335057b186e6d |
|
BLAKE2b-256 | b5a1ff0251bd578e3b39d7a8f66782406e1b6b1404ca527f7a0567263032034d |
Provenance
File details
Details for the file wagtail_factories-2.0.0-py2.py3-none-any.whl
.
File metadata
- Download URL: wagtail_factories-2.0.0-py2.py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2198e791854ef3883812f532a4d1b364aae1c68abc58a48b8ecec8c61e4a151f |
|
MD5 | ac8081cf8f61733970047a83bdd2e2c8 |
|
BLAKE2b-256 | 47f037727b7a97b0158b6934c5bef9a2233d64eadea3c353086ee31bbd03db33 |