diff --git a/tbx/core/tests/test_models.py b/tbx/core/tests/test_models.py index 57c9fabe6..7f218b5fa 100644 --- a/tbx/core/tests/test_models.py +++ b/tbx/core/tests/test_models.py @@ -18,7 +18,7 @@ class TestPageFactory(TestCase): # Exclude these modules from the check. # (They currently don't have factories. Un-exclude once they have factories.) - EXCLUDE = ["tbx.events", "tbx.impact_reports", "tbx.services"] + EXCLUDE = ["tbx.events", "tbx.impact_reports"] def test_pages(self): app_configs = apps.get_app_configs() diff --git a/tbx/services/factories.py b/tbx/services/factories.py new file mode 100644 index 000000000..539e1c2ce --- /dev/null +++ b/tbx/services/factories.py @@ -0,0 +1,30 @@ +import factory +import wagtail_factories +from tbx.core.factories import StoryBlockFactory + +from .models import ServiceAreaPage, ServicePage + + +class ServicePageFactory(wagtail_factories.PageFactory): + class Meta: + model = ServicePage + + title = factory.Faker("text", max_nb_chars=100) + + @factory.post_generation + def body(obj, create, extracted, **kwargs): + blocks = kwargs or {"0": "paragraph"} + obj.body = StoryBlockFactory(**blocks) + + +class ServiceAreaPageFactory(wagtail_factories.PageFactory): + class Meta: + model = ServiceAreaPage + + title = factory.Faker("text", max_nb_chars=100) + subtitle = factory.Faker("text", max_nb_chars=100) + + @factory.post_generation + def body(obj, create, extracted, **kwargs): + blocks = kwargs or {"0": "paragraph"} + obj.body = StoryBlockFactory(**blocks)