Skip to content

Commit

Permalink
Add page factories for the services module
Browse files Browse the repository at this point in the history
  • Loading branch information
SharmaineLim committed Jan 10, 2025
1 parent 3669039 commit e1b07dd
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tbx/core/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
30 changes: 30 additions & 0 deletions tbx/services/factories.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit e1b07dd

Please sign in to comment.