diff options
author | Matthew Lemon <y@yulqen.org> | 2024-05-16 16:57:14 +0100 |
---|---|---|
committer | Matthew Lemon <y@yulqen.org> | 2024-05-16 16:57:14 +0100 |
commit | 55e5dfbd51924f1f23e5a651d830206be01e376c (patch) | |
tree | e3ea881742b3afc2c473c890cbfd8d98d20cc4a9 /pyblackbird_cc/resources/factories.py | |
parent | 65c49ea41ecd8e1cce07db1b258a93132cb634d4 (diff) |
wip: starting to test feature resource functionality with factories
Diffstat (limited to '')
-rw-r--r-- | pyblackbird_cc/resources/factories.py | 31 |
1 files changed, 31 insertions, 0 deletions
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"]) |