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.
49 lines
1.2 KiB
49 lines
1.2 KiB
import os
|
|
import pytz
|
|
|
|
import factory
|
|
import factory.fuzzy
|
|
|
|
from functools import partial
|
|
|
|
from django.contrib.auth import get_user_model
|
|
from django.conf import settings
|
|
|
|
|
|
USER_PASSWORD = 'test'
|
|
AVATAR_SAMPLE_IMAGE = os.path.join(settings.IMAGE_SAMPLES_DIR, 'simple.jpg')
|
|
|
|
Faker = partial(factory.Faker, locale='ru_RU')
|
|
|
|
|
|
class UserFactory(factory.django.DjangoModelFactory):
|
|
first_name = Faker('first_name')
|
|
last_name = Faker('last_name')
|
|
email = Faker('email')
|
|
password = factory.PostGenerationMethodCall('set_password', USER_PASSWORD)
|
|
is_active = True
|
|
is_staff = False
|
|
date_joined = Faker(
|
|
'past_datetime',
|
|
start_date='-30d',
|
|
tzinfo=pytz.UTC
|
|
)
|
|
|
|
class Meta:
|
|
model = get_user_model()
|
|
|
|
|
|
class AccountFactory(factory.django.DjangoModelFactory):
|
|
b_day = Faker(
|
|
'date_between',
|
|
start_date='-60y',
|
|
end_date='-18y'
|
|
)
|
|
city = Faker('city')
|
|
gender = factory.fuzzy.FuzzyChoice(range(1, 2))
|
|
owner = factory.SubFactory(UserFactory)
|
|
photo = factory.django.ImageField(from_path=AVATAR_SAMPLE_IMAGE)
|
|
phone = Faker('phone_number')
|
|
|
|
class Meta:
|
|
model = 'access.Account'
|
|
|