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"])