27 lines
874 B
Python
27 lines
874 B
Python
import random
|
|
|
|
import factory
|
|
from django.contrib.auth import get_user_model
|
|
|
|
from core.factories import fake
|
|
from rooms.models import Room, RoomEntry
|
|
from user.models import UserGroup
|
|
|
|
|
|
class RoomFactory(factory.django.DjangoModelFactory):
|
|
class Meta:
|
|
model = Room
|
|
|
|
title = factory.LazyAttribute(lambda x: fake.sentence(nb_words=random.randint(4, 8)))
|
|
user_group = factory.Iterator(UserGroup.objects.all())
|
|
appearance = factory.LazyAttribute(lambda x: random.choice(['red', 'green', 'brown']))
|
|
|
|
|
|
class RoomEntryFactory(factory.django.DjangoModelFactory):
|
|
class Meta:
|
|
model = RoomEntry
|
|
|
|
title = factory.LazyAttribute(lambda x: fake.sentence(nb_words=random.randint(8, 12)))
|
|
description = factory.LazyAttribute(lambda x: fake.sentence(nb_words=random.randint(20, 30)))
|
|
author = factory.Iterator(get_user_model().objects.all())
|