change to factory
This commit is contained in:
parent
7b93c6970e
commit
21fa7e73b9
|
@ -5,59 +5,56 @@ 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
|
||||
|
||||
factory.Faker.override_default_locale('ru_RU');
|
||||
|
||||
class ApartmentFactory(factory.django.DjangoModelFactory):
|
||||
|
||||
class Meta:
|
||||
model = Apartament
|
||||
|
||||
# Base data
|
||||
price = faker.random.randint(2, 10) * 5000
|
||||
price = factory.Faker('random_number')
|
||||
lastPrice = price
|
||||
bail = faker.random.randint(1, 10) * 100
|
||||
bail = factory.Faker('random_number')
|
||||
|
||||
# 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
|
||||
agencyCommission = factory.Faker('random_number')
|
||||
utilitiesPrice = factory.Faker('random_number')
|
||||
minimumLeasePeriod = factory.Faker('random_number')
|
||||
|
||||
address = faker.address();
|
||||
description = ' '.join([faker.sentence() for i in range(5)]);
|
||||
address = factory.Faker('address')
|
||||
description = factory.Faker('sentence')
|
||||
|
||||
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)
|
||||
perimetrs = factory.Faker('random_number')
|
||||
rooms = factory.Faker('random_number')
|
||||
ceilingHeight = factory.Faker('random_number')
|
||||
floorHouse = factory.Faker('random_number')
|
||||
floor = factory.Faker('random_number')
|
||||
|
||||
phoneNumber = faker.phone_number()
|
||||
phoneNumber = factory.Faker('phone_number')
|
||||
|
||||
timeToBus = faker.random.randint(2, 12) * 5
|
||||
timeToTrain = faker.random.randint(2, 12) * 5
|
||||
timeToBus = factory.Faker('random_number')
|
||||
timeToTrain = factory.Faker('random_number')
|
||||
|
||||
# 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)
|
||||
isFurniture = factory.Faker('boolean')
|
||||
isAnimal = factory.Faker('boolean')
|
||||
isTelevision = factory.Faker('boolean')
|
||||
isChild = factory.Faker('boolean')
|
||||
isInternet = factory.Faker('boolean')
|
||||
isBathroom = factory.Faker('boolean')
|
||||
isRefrigerator = factory.Faker('boolean')
|
||||
isWasher = factory.Faker('boolean')
|
||||
isAirConditioning = factory.Faker('boolean')
|
||||
isFreshRepair = factory.Faker('boolean')
|
||||
|
||||
# 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)
|
||||
isElevator = factory.Faker('boolean')
|
||||
isParking = factory.Faker('boolean')
|
||||
isGarbageChute = factory.Faker('boolean')
|
||||
isConcierge = factory.Faker('boolean')
|
||||
|
||||
views = faker.random.randint(10, 666)
|
||||
views = factory.Faker('random_number')
|
||||
|
||||
dateCreate = faker.date_between('-1y')
|
||||
dateCreate = factory.Faker('date')
|
Loading…
Reference in New Issue