You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

62 lines
1.9 KiB

import uuid
import factory
import factory.fuzzy
from functools import partial
from access.factories import UserFactory
from access import groups
IMAGE_URL = 'https://dummyimage.com/240x240/000/fff.png'
BIG_IMAGE_URL = 'https://dummyimage.com/1200x800/000/fff.png'
BIG_MOBILE_IMAGE_URL = 'https://dummyimage.com/600x400/000/fff.png'
Faker = partial(factory.Faker, locale='ru_RU')
class CourseFactory(factory.django.DjangoModelFactory):
class Meta:
model = 'courses.Course'
token = factory.LazyFunction(uuid.uuid4)
slug = factory.LazyAttribute(lambda x: factory.Faker('sentence').
generate({'nb_words': 3}).replace(' ', '-').replace('.', ''))
title = factory.LazyAttribute(lambda x: Faker('sentence').generate({'nb_words': 4}))
description = factory.LazyAttribute(
lambda x: '\n'.join(Faker('paragraphs').generate({'nb': 15}))
)
direction = factory.fuzzy.FuzzyChoice(range(1, 5))
public = True
image = IMAGE_URL
big_image = BIG_IMAGE_URL
big_mobile_image = BIG_MOBILE_IMAGE_URL
@factory.lazy_attribute
def teacher_tokens(self):
teacher = UserFactory(groups=(groups.TEACHERS,))
return [teacher.out_key]
class TopicFactory(factory.django.DjangoModelFactory):
class Meta:
model = 'courses.Topic'
course = factory.SubFactory(CourseFactory)
title = factory.LazyAttribute(lambda x: Faker('sentence').generate({'nb_words': 4}))
description = factory.LazyAttribute(
lambda x: '\n'.join(Faker('paragraphs').generate({'nb': 15}))
)
sort = 0
class LessonFactory(factory.django.DjangoModelFactory):
class Meta:
model = 'courses.Lesson'
token = factory.LazyFunction(uuid.uuid4)
key = factory.LazyFunction(uuid.uuid4)
topic = factory.SubFactory(TopicFactory)
title = factory.LazyAttribute(lambda x: Faker('sentence').generate({'nb_words': 4}))
sort = 0