factories# OrganizationFactory# Bases: DjangoModelFactory Source code in src/apps/actors/factories.py 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26class OrganizationFactory(factory.django.DjangoModelFactory): class Meta: model = Organization id = factory.Faker("uuid4") pref_label = factory.Dict({"en": factory.Sequence(lambda n: f"Organization-{n}")}) in_scheme = settings.ORGANIZATION_SCHEME parent = None is_reference_data = True @factory.lazy_attribute_sequence def code(obj, n): prefix = "" if obj.parent: prefix = f"{obj.parent.code}-" return f"{prefix}{n}" @factory.lazy_attribute def url(obj): return f"https://{settings.ORGANIZATION_BASE_URI}{obj.code}" PersonFactory# Bases: DjangoModelFactory Source code in src/apps/actors/factories.py 29 30 31 32 33 34class PersonFactory(factory.django.DjangoModelFactory): class Meta: model = Person name = factory.Faker("name") email = factory.Faker("email") ActorFactory# Bases: DjangoModelFactory Source code in src/apps/actors/factories.py 37 38 39 40 41 42class ActorFactory(factory.django.DjangoModelFactory): class Meta: model = Actor person = factory.SubFactory(PersonFactory) organization = factory.SubFactory(OrganizationFactory)