From 55e5dfbd51924f1f23e5a651d830206be01e376c Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Thu, 16 May 2024 16:57:14 +0100 Subject: wip: starting to test feature resource functionality with factories --- pyblackbird_cc/resources/factories.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 pyblackbird_cc/resources/factories.py (limited to 'pyblackbird_cc/resources/factories.py') diff --git a/pyblackbird_cc/resources/factories.py b/pyblackbird_cc/resources/factories.py new file mode 100644 index 0000000..b78822d --- /dev/null +++ b/pyblackbird_cc/resources/factories.py @@ -0,0 +1,31 @@ +import factory + + +class ResourceTypeModelFactory(factory.django.DjangoModelFactory): + class Meta: + model = "resources.ResourceType" + django_get_or_create = ("name",) + + name = factory.Sequence(lambda n: f"Default Resource Type {n}") + + +class ResourceCategoryModelFactory(factory.django.DjangoModelFactory): + class Meta: + model = "resources.ResourceCategory" + django_get_or_create = ("name",) + + name = factory.Sequence(lambda n: f"Default Resource Category {n}") + + +class ResourceModelFactory(factory.django.DjangoModelFactory): + class Meta: + model = "resources.Resource" + + name = factory.Sequence(lambda n: f"Default Resource {n}") + thumbnail_filenames = factory.Sequence(lambda n: [f"thumbnail_{n}.jpg"]) + resource_type = factory.SubFactory(ResourceTypeModelFactory) + main_resource_category = factory.SubFactory(ResourceCategoryModelFactory) + additional_resource_category = factory.SubFactory(ResourceCategoryModelFactory) + description = factory.Sequence(lambda n: f"Default description {n}") + age_range = factory.Iterator(["5-7", "7-10", "10+"]) + curriculum = factory.Iterator(["English", "Scottish"]) -- cgit v1.2.3