aboutsummaryrefslogtreecommitdiffstats
path: root/pyblackbird_cc/resources/factories.py
blob: b78822d39950ccc4356f627c45d8a965e17cf4b6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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"])