legacy/pairent_backend/pairent_app/factories.py

63 lines
2.0 KiB
Python
Raw Normal View History

2023-05-05 13:03:33 +02:00
import factory
import factory.fuzzy
from django.core.validators import RegexValidator
import math
import faker as fake_lib
from faker.providers import internet
faker = fake_lib.Factory.create('ru_RU');
from pairent_app.models import Apartament
class ApartmentFactory(factory.django.DjangoModelFactory):
class Meta:
model = Apartament
# Base data
price = faker.random.randint(2, 10) * 5000
lastPrice = price
bail = faker.random.randint(1, 10) * 100
# agency comission is either 10% or 15%
agencyCommission = int(price / (10 + (faker.random.randint(0,1) * 5)))
utilitiesPrice = faker.random.randint(4, 16) * 1000
minimumLeasePeriod = math.ceil(faker.random.randint(100,160) / 100) * 6
address = faker.address();
description = ' '.join([faker.sentence() for i in range(5)]);
perimetrs = faker.random.randint(150,400) / 10
rooms = faker.random.randint(1, 4) # 0 - гостинка, 4 - трешка
ceilingHeight = faker.random.randint(5, 7)
floorHouse = faker.random.randint(2, 20)
floor = faker.random.randint(1, floorHouse)
phoneNumber = faker.phone_number()
timeToBus = faker.random.randint(2, 12) * 5
timeToTrain = faker.random.randint(2, 12) * 5
# Apartment props
isFurniture = faker.random.randint(0, 1)
isAnimal = faker.random.randint(0, 1)
isTelevision = faker.random.randint(0, 1)
isChild = faker.random.randint(0, 1)
isInternet = faker.random.randint(0, 1)
isBathroom = faker.random.randint(0, 1)
isRefrigerator = faker.random.randint(0, 1)
isWasher = faker.random.randint(0, 1)
isAirConditioning = faker.random.randint(0, 1)
isFreshRepair = faker.random.randint(0, 1)
# House props
isElevator = faker.random.randint(0, 1)
isParking = faker.random.randint(0, 1)
isGarbageChute = faker.random.randint(0, 1)
isConcierge = faker.random.randint(0, 1)
views = faker.random.randint(10, 666)
dateCreate = faker.date_between('-1y')