Factory Boy classes for generating test data in Wagtail CMS projects.
Wagtail Factories is a Python library that provides Factory Boy classes for generating test data in Wagtail CMS projects. It allows developers to easily create instances of Wagtail pages, blocks, and other models for testing purposes. The library simplifies the process of setting up complex data structures like StreamFields with nested blocks.
Wagtail developers and Django developers who need to write tests for Wagtail-based applications and want a structured way to generate test fixtures.
It offers a declarative and reusable approach to creating test data specifically tailored for Wagtail's data models, reducing boilerplate code and improving test reliability. Developers choose it because it integrates seamlessly with factory_boy and provides specialized factories for Wagtail's unique block and page structures.
Factory boy classes for wagtail
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Offers dedicated factories for Wagtail's complex StreamField and block types like StructBlock and ListBlock, enabling easy creation of nested data structures as shown in the README's carousel example.
Seamlessly builds on factory_boy, allowing developers to use its declarative syntax and deep object declaration for setting nested field values, reducing test boilerplate.
Eliminates manual setup of Wagtail models in tests, making code cleaner and more maintainable through reusable factory classes, as demonstrated in the provided usage snippets.
Supports customizable field values via keyword arguments, giving precise control over test data, such as overriding defaults in nested blocks like in the body__0__carousel example.
The README explicitly states that documentation is 'still in progress', forcing users to rely on test examples, which can slow onboarding and increase debugging time.
Version 3.0 introduced mandatory updates, such as requiring SubFactory wrappers for block factories in the alternative StreamFieldFactory syntax, potentially breaking existing test code.
Tightly coupled to factory_boy, so teams not already using it must adopt an additional dependency, adding complexity to the toolchain and learning curve.