def test_biased_high_only(self): fake_uniform = lambda low, high: low + high fuzz = fuzzy.FuzzyFloat(8.0) with mock.patch('factory.random.randgen.uniform', fake_uniform): res = utils.evaluate_declaration(fuzz) self.assertEqual(8.0, res)
def test_default_precision(self): fake_uniform = lambda low, high: low + high + 0.000000000000011 fuzz = fuzzy.FuzzyFloat(8.0) with mock.patch('factory.random.randgen.uniform', fake_uniform): res = utils.evaluate_declaration(fuzz) self.assertEqual(8.00000000000001, res)
class AssetStateFactory(Factory): class Meta: model = AssetState id = Sequence(lambda x: x) asset = SubFactory(AssetFactory) start = fuzzy.FuzzyDate(START_DATE, END_DATE) end = LazyAttribute(lambda x: x.start + timedelta(minutes=DEFAULT_MIN_DURATION)) available = True charge = fuzzy.FuzzyFloat(MIN, MAX)
class InvoiceItemFactory(factory.DjangoModelFactory): class Meta: model = InvoiceItem invoice = factory.SubFactory('invoices.test.factories.InvoiceFactory') name = factory.Faker('job', locale='bg_BG') measure = fuzzy.FuzzyChoice(["hours", "weeks"]) quantity = fuzzy.FuzzyInteger(1, 164) unit_price = fuzzy.FuzzyFloat(5.5, 1000.4) discount = 0
def test_definition(self): """Tests all ways of defining a FuzzyFloat.""" fuzz = fuzzy.FuzzyFloat(2.0, 3.0) for _i in range(20): res = utils.evaluate_declaration(fuzz) self.assertTrue(2.0 <= res <= 3.0, "value %d is not between 2.0 and 3.0" % res) fuzz = fuzzy.FuzzyFloat(4.0) for _i in range(20): res = utils.evaluate_declaration(fuzz) self.assertTrue(0.0 <= res <= 4.0, "value %d is not between 0.0 and 4.0" % res) fuzz = fuzzy.FuzzyDecimal(1.0, 4.0, precision=5) for _i in range(20): res = utils.evaluate_declaration(fuzz) self.assertTrue(1.0 <= res <= 4.0, "value %d is not between 1.0 and 4.0" % res) self.assertTrue(res.as_tuple().exponent, -5)
class ContentTypeFactory(factory.DjangoModelFactory): class Meta: model = EnevoContentType id = factory.Sequence(lambda n: n) category = fuzzy.FuzzyInteger(0, 50) category_name = fuzzy.FuzzyText(length=30) name = fuzzy.FuzzyText(length=30) state = fuzzy.FuzzyText(length=30) weight_to_volume_ratio = fuzzy.FuzzyFloat(0.5, 100.0) last_modified = fuzzy.FuzzyDateTime(start_dt=timezone.now())
class PayloadVersion1(factory.DictFactory): id = factory.Faker('uuid4') passageAt = factory.LazyFunction(timezone.now) version = "passage-v1" straat = factory.Faker('name') rijstrook = fuzzy.FuzzyInteger(1, 10) rijrichting = fuzzy.FuzzyChoice((-1, 1)) cameraId = factory.Faker('uuid4') cameraNaam = factory.Faker('first_name') cameraKijkrichting = fuzzy.FuzzyFloat(0, 360) cameraLocatie = factory.LazyFunction(get_point_in_amsterdam_as_json) kentekenLand = fuzzy.FuzzyText(length=2) kentekenNummerBetrouwbaarheid = fuzzy.FuzzyInteger(1, 1000) kentekenLandBetrouwbaarheid = fuzzy.FuzzyInteger(1, 1000) kentekenKaraktersBetrouwbaarheid = factory.LazyFunction( kenteken_karakter_betrouwbaarheid ) indicatieSnelheid = fuzzy.FuzzyFloat(0, 500) automatischVerwerkbaar = factory.Faker('boolean', chance_of_getting_true=50) voertuigSoort = fuzzy.FuzzyChoice(VOERTUIG_SOORTEN) merk = factory.Faker('first_name') inrichting = factory.Faker('first_name') datumEersteToelating = fuzzy.FuzzyDate(datetime.date(2008, 1, 1)) datumTenaamstelling = fuzzy.FuzzyDate(datetime.date(2008, 1, 1)) toegestaneMaximumMassaVoertuig = fuzzy.FuzzyInteger(1, 32000) europeseVoertuigcategorie = fuzzy.FuzzyText(length=2) europeseVoertuigcategorieToevoeging = fuzzy.FuzzyText(length=1) taxiIndicator = factory.Faker('boolean', chance_of_getting_true=50) maximaleConstructieSnelheidBromsnorfiets = fuzzy.FuzzyInteger(0, 500) brandstoffen = factory.LazyFunction(get_brandstoffen_v1) extraData = {} diesel = factory.LazyAttribute( lambda self: int('Diesel' in {x['brandstof'] for x in self.brandstoffen}) ) gasoline = factory.LazyAttribute( lambda self: int('Benzine' in {x['brandstof'] for x in self.brandstoffen}) ) electric = factory.LazyAttribute( lambda self: int('Elektriciteit' in {x['brandstof'] for x in self.brandstoffen}) ) versitKlasse = fuzzy.FuzzyText()
class StationFactory(factory.django.DjangoModelFactory): """Station model factory.""" owner = factory.SubFactory(UserFactory) name = fuzzy.FuzzyText() image = factory.django.ImageField() alt = fuzzy.FuzzyInteger(0, 800) lat = fuzzy.FuzzyFloat(-20, 70) lng = fuzzy.FuzzyFloat(-180, 180) featured = fuzzy.FuzzyChoice(choices=[True, False]) @factory.post_generation def antennas(self, create, extracted, **kwargs): if not create: return if extracted: for antenna in extracted: self.antenna.add(antenna) class Meta: model = Station
class PeakFactory(DjangoModelFactory): class Meta: model = Peak exclude = ("lat", "lon", "alt", "srid") lat = float(fake.latitude()) lon = float(fake.longitude()) alt = fuzzy.FuzzyFloat(1000, 5000) srid = 4326 name = fake.name() coordinates = factory.LazyAttribute( lambda o: Point(o.lon, o.lat, o.alt, srid=o.srid))
class CountryWeeklyStatusFactory(django_factory.DjangoModelFactory): country = SubFactory(CountryFactory) year = fuzzy.FuzzyInteger(1900, 2200) week = fuzzy.FuzzyInteger(1, 53) schools_connected = fuzzy.FuzzyInteger(0, 1000) schools_connectivity_unknown = fuzzy.FuzzyInteger(0, 1000) schools_connectivity_no = fuzzy.FuzzyInteger(0, 1000) schools_connectivity_moderate = fuzzy.FuzzyInteger(0, 1000) schools_connectivity_good = fuzzy.FuzzyInteger(0, 1000) connectivity_speed = fuzzy.FuzzyInteger(1, 1000000) integration_status = fuzzy.FuzzyChoice(dict(CountryWeeklyStatus.INTEGRATION_STATUS_TYPES).keys()) avg_distance_school = fuzzy.FuzzyFloat(0.0, 1000.0) class Meta: model = CountryWeeklyStatus
class DrukteindexFactory(factory.DjangoModelFactory): class Meta: model = models.Drukteindex index = fuzzy.FuzzyInteger(low=10000000000000, high=19000009999999) timestamp = fuzzy.FuzzyDateTime( datetime(2016, 1, 1, tzinfo=timezone.utc), datetime(2017, 1, 1, tzinfo=timezone.utc)) vollcode = fuzzy.FuzzyText() weekday = fuzzy.FuzzyInteger(0, 6) hour = fuzzy.FuzzyFloat(0, 23) google_live = fuzzy.FuzzyFloat(0, 1) google_week = fuzzy.FuzzyFloat(0, 1) gvb_buurt = fuzzy.FuzzyFloat(0, 1) gvb_stad = fuzzy.FuzzyFloat(0, 1) verblijversindex = fuzzy.FuzzyFloat(0, 1) google = fuzzy.FuzzyFloat(0, 1) gvb = fuzzy.FuzzyFloat(0, 1) drukte_index = fuzzy.FuzzyFloat(0, 1)
class AssetFactory(Factory): class Meta: model = Asset id = Sequence(lambda x: x) name = LazyAttribute(lambda x: f"Asset {x.id}") capacity = 100 running_cost_per_mw_hr = 0 min_required_profit = fuzzy.FuzzyFloat(MIN, MAX) max_import_mw_hr = fuzzy.FuzzyFloat(MIN, MAX) max_export_mw_hr = fuzzy.FuzzyFloat(MIN, MAX) single_import_mw_hr = None single_export_mw_hr = None min_zero_time = fuzzy.FuzzyFloat(MIN, MAX) min_non_zero_time = fuzzy.FuzzyFloat(MIN, MAX) notice_to_deviate_from_zero = fuzzy.FuzzyFloat(MIN, MAX) notice_to_deliver_bid = fuzzy.FuzzyFloat(MIN, MAX) max_delivery_period = fuzzy.FuzzyFloat(MIN, MAX)
class MeteoFactory(factory.django.DjangoModelFactory): class Meta: model = 'testapp.Meteo' date = factory.Faker('date') provider = factory.SubFactory(ProviderFactory) city = factory.Faker('city') temperature = fuzzy.FuzzyFloat(-10, 50) humidity = fuzzy.FuzzyInteger(0, 100) @classmethod def create_batch_provider(self, count, provider_count, **kwargs): meteos = [] for _ in range(provider_count): provider = ProviderFactory.create() meteos.extend(self.create_batch(count, provider=provider, **kwargs)) return meteos
class SubmissionAttemptFactory(factory.DjangoModelFactory): class Meta: model = SubmissionAttempt class Params: our_tz = get_current_timezone() VISITS_START = datetime.datetime(2016, 2, 26, 8, 0, 10, tzinfo=our_tz) VISITS_END = datetime.datetime(2016, 6, 16, 17, 35, 9, tzinfo=our_tz) attempt_key = factory.Sequence(lambda n: "key %d" % n) page = factory.SubFactory(PageFactory) lms_user = factory.SubFactory(LMSUserFactory) attempted_at = faker.Faker('date_time_between_dates', datetime_start=Params.VISITS_START, datetime_end=Params.VISITS_END) grade = fuzzy.FuzzyFloat(10.0) @classmethod def _setup_next_sequence(cls): return 1000000
class Voertuig(factory.DictFactory): kenteken = factory.SubFactory(Kenteken) jaarEersteToelating = fuzzy.FuzzyInteger(1990, 2020) toegestaneMaximumMassaVoertuig = fuzzy.FuzzyInteger(0, 1000) europeseVoertuigcategorie = fuzzy.FuzzyText(length=2) europeseVoertuigcategorieToevoeging = fuzzy.FuzzyChoice(string.ascii_uppercase) taxiIndicator = factory.Faker('boolean', chance_of_getting_true=50) maximaleConstructiesnelheidBromSnorfiets = fuzzy.FuzzyInteger(0, 500) versitKlasse = fuzzy.FuzzyText() massaLedigVoertuig = fuzzy.FuzzyInteger(0, 500) aantalAssen = fuzzy.FuzzyInteger(0, 10) aantalStaanplaatsen = fuzzy.FuzzyInteger(0, 100) aantalWielen = fuzzy.FuzzyInteger(0, 12) aantalZitplaatsen = fuzzy.FuzzyInteger(0, 100) handelsbenaming = factory.Faker('first_name') lengte = fuzzy.FuzzyInteger(0, 500) breedte = fuzzy.FuzzyInteger(0, 500) maximumMassaTrekkenOngeremd = fuzzy.FuzzyInteger(0, 5000) maximumMassaTrekkenGeremd = fuzzy.FuzzyInteger(0, 5000) voertuigSoort = fuzzy.FuzzyChoice(VOERTUIG_SOORTEN) merk = factory.Faker('first_name') inrichting = factory.Faker('first_name') brandstoffen = factory.LazyFunction(get_brandstoffen_v2) indicatieSnelheid = fuzzy.FuzzyFloat(0, 150)
class Locatie(factory.DictFactory): longitude = fuzzy.FuzzyFloat(*AMSTERDAM_LONGITUDE) latitude = fuzzy.FuzzyFloat(*AMSTERDAM_LATITUDE)
class Camera(factory.DictFactory): id = factory.Faker('uuid4') kijkrichting = fuzzy.FuzzyFloat(0, 360) locatie = factory.SubFactory(Locatie) naam = factory.Faker('name') straat = factory.Faker('name')
class CarFactory(MakeFactoryMixin, DjangoModelFactory): REGIONAL_PREFIXES = ( "AA", "KA", "AB", "KB", "AC", "KC", "AE", "KE", "AH", "KH", "AI", "KI", "AK", "KK", "AM", "KM", "AO", "KO", "AP", "KP", "AT", "KT", "AX", "KX", "BA", "HA", "BB", "HB", "BC", "HC", "BE", "HE", "BH", "HH", "BI", "HI", "BK", "HK", "BM", "HM", "BO", "HO", "BP", "HP", "BT", "HT", "BX", "HX", "CA", "IA", "CB", "IB", "CC", "IC", "CE", "IE", "CH", "IH", "II", ) COLORS = ("white", "black", "silver", "gray", "brown", "red", "blue", "green") MODELS = { "Peugeot": ( "108", "208", "301", "308", "408", "508", "Bipper", "Partner", "Expert", "Boxer", ), "Citroen": ( "C1", "C3", "C4", "C5", "DS 3", "DS 4", "DS 4S", "DS 5", "Berlingo", "Jumper", "Jumpy", "Nemo", ), "Suzuki": ( "Alto", "Baleno", "Celerio", "Lapin", "Spacia", "Swift", "Carry", "Jimny", "Vitara", "Every", "Landy", ), "Fiat": ( "Panda", "500", "Uno", "Linea", "Tipo", "Doblò", "Ducato", "Fiorino", "Qubo", "Talento", ), "Honda": ( "Accord", "Civic", "Jazz", "Insight", "Inspire", "Legend", "Acty", "Ridgeline", "CR-V", "HR-V", "Acty", "Freed", "Odyssey", ), "Ford": ( "C-Max", "Fiesta", "Figo", "Fusion", "Mondeo", "Focus", "Ka", "Ranger", "Super Duty", "Galaxy", "S-Max", "Transit", ), "Hyundai": ( "i10", "i20", "i30", "Elantra", "i40", "Accent", "Atos", "Visto" "Elantra", "Eon", "ix20", "Cargo Truck", "Porter", "Xcient", ), "Kia": ( "Ceed", "Cerato", "Optima", "Picanto", "Quoris", "Ray", "Stinger", "Carens", "Carnival", "Venga", "Besta", "Bongo", ), "Renault": ( "Clio", "Fluence", "Mégane", "Talisman", "Twingo", "Scénic", "Captur", "Espace", "Kadjar", "Kangoo", "Trafic", ), "Dacia": ("Logan", "Sandero", "Lodgy", "Duster", "Lodgy", "Dokker"), "Nissan": ( "Altima", "Cima", "Fuga", "Almera", "Leaf", "Micra", "Navara", "Patrol", "Juke", "Murano", "Pathfinder", "Clipper", "Cabstar", "Atlas", ), "Toyota": ( "Auris", "Aygo", "Camry", "Corolla", "Prius", "Yaris", "Hilux", "Land Cruiser", "C-HR", "RAV4", "Avanza", "Esquire", "Estima", "Innova", "Pixis", "Sienna", "Dyna", "ToyoAce", ), "SEAT": ("Toledo", "Ibiza", "León", "Mii", "Alhambra", "Arona", "Ateca"), "Škoda": ("Citigo", "Fabia", "Octavia", "Rapid", "Superb", "Kodiaq", "Karoq"), "Volkswagen": ( "Bora", "Fox", "Golf", "Jetta", "Passat", "Polo", "Up", "Vento", "Voyage", "T-Roc", "Tiguan", "Touareg", "Caddy", "Sharan", "Suran", "Touran", "Amarok", "Saveiro", "Transporter", "Crafter", ), } fuel_consumption = fuzzy.FuzzyFloat(3, 10) country = fuzzy.FuzzyChoice(COUNTRIES) class Meta: model = Car exclude = ("REGIONAL_PREFIXES", "COLORS", "MODELS") @lazy_attribute def plates(self): return "{regional_prefix}{four_digits}{two_letters}".format( regional_prefix=random.choice(self.REGIONAL_PREFIXES), four_digits="".join(random.choices(string.digits, k=4)), two_letters="".join(random.choices("ABEIKMHOPCTX", k=2)), ) @lazy_attribute def description(self): manufacturer = random.choice(list(self.MODELS.keys())) return "{color} {manufacturer} {model} {year}".format( color=random.choice(self.COLORS).capitalize(), manufacturer=manufacturer, model=random.choice(self.MODELS[manufacturer]), year=random.randrange(1990, now().year), )
class ApartmentFactory(factory.Factory): class Meta: model = ApartmentTest _language = fuzzy.FuzzyChoice(["en", "fi", "sv"]) project_id = fuzzy.FuzzyInteger(0, 9999999999) project_uuid = str(uuid.uuid4()) project_housing_company = fuzzy.FuzzyText() project_holding_type = "RIGHT_OF_RESIDENCE_APARTMENT" project_street_address = fuzzy.FuzzyText() project_postal_code = fuzzy.FuzzyText(length=6, chars=string.digits) project_city = "Helsinki" project_district = fuzzy.FuzzyText() project_realty_id = fuzzy.FuzzyText() project_construction_year = fuzzy.FuzzyInteger(2000, 3000) project_new_development_status = fuzzy.FuzzyChoice( NEW_DEVELOPMENT_STATUS_MAPPING.keys()) project_new_housing = True project_apartment_count = fuzzy.FuzzyInteger(0, 9999999999) project_parkingplace_count = fuzzy.FuzzyInteger(0, 9999999999) project_has_elevator = True project_has_sauna = True project_construction_materials = factory.List( [fuzzy.FuzzyText() for _ in range(2)]) project_roof_material = fuzzy.FuzzyText() project_heating_options = factory.List( [fuzzy.FuzzyText() for _ in range(2)]) project_energy_class = fuzzy.FuzzyText() project_site_area = fuzzy.FuzzyFloat(0, 9999999999) project_site_owner = fuzzy.FuzzyChoice(["Oma", "Vuokra"]) project_site_renter = fuzzy.FuzzyText() project_sanitation = fuzzy.FuzzyText() project_zoning_info = fuzzy.FuzzyText() project_zoning_status = fuzzy.FuzzyText() project_building_type = "BLOCK_OF_FLATS" project_description = fuzzy.FuzzyText(length=200) url = fuzzy.FuzzyText(length=20) project_accessibility = fuzzy.FuzzyText() project_smoke_free = fuzzy.FuzzyText() project_publication_start_time = (fuzzy.FuzzyDateTime( timezone.now()).fuzz().strftime("%Y-%m-%dT%H:%M:%S%z")) project_publication_end_time = (fuzzy.FuzzyDateTime( timezone.now()).fuzz().strftime("%Y-%m-%dT%H:%M:%S%z")) project_premarketing_start_time = fuzzy.FuzzyDateTime(timezone.now()) project_premarketing_end_time = fuzzy.FuzzyDateTime(timezone.now()) project_application_start_time = fuzzy.FuzzyDateTime(timezone.now()) project_application_end_time = fuzzy.FuzzyDateTime(timezone.now()) project_material_choice_dl = fuzzy.FuzzyDate(date.today()) project_shareholder_meeting_date = fuzzy.FuzzyDate(date.today()) project_estimated_completion = fuzzy.FuzzyText() project_estimated_completion_date = fuzzy.FuzzyDate(date.today()) project_completion_date = fuzzy.FuzzyDate(date.today()) project_posession_transfer_date = fuzzy.FuzzyDate(date.today()) project_attachment_urls = factory.List( [fuzzy.FuzzyText() for _ in range(2)]) project_main_image_url = fuzzy.FuzzyText() project_image_urls = factory.List([fuzzy.FuzzyText() for _ in range(2)]) project_virtual_presentation_url = fuzzy.FuzzyText() project_acc_salesperson = fuzzy.FuzzyText() project_acc_financeofficer = fuzzy.FuzzyText() project_project_manager = fuzzy.FuzzyText() project_constructor = fuzzy.FuzzyText() project_housing_manager = fuzzy.FuzzyText() project_estate_agent = fuzzy.FuzzyText() project_estate_agent_email = Faker("email") project_estate_agent_phone = fuzzy.FuzzyText() project_coordinate_lat = fuzzy.FuzzyFloat(-90, 90) project_coordinate_lon = fuzzy.FuzzyFloat(-180, 180) project_state_of_sale = fuzzy.FuzzyChoice(ProjectStateOfSale) apartment_state_of_sale = fuzzy.FuzzyChoice(ApartmentStateOfSale) uuid = fuzzy.FuzzyAttribute(get_uuid) apartment_address = fuzzy.FuzzyText() apartment_number = fuzzy.FuzzyInteger(0, 99) housing_shares = fuzzy.FuzzyText() living_area = fuzzy.FuzzyFloat(0, 9999999999) floor = fuzzy.FuzzyInteger(0, 9999999999) floor_max = fuzzy.FuzzyInteger(0, 9999999999) showing_times = factory.List([ fuzzy.FuzzyDateTime( timezone.now()).fuzz().strftime("%Y-%m-%dT%H:%M:%S%z") for _ in range(2) ]) apartment_structure = fuzzy.FuzzyText() room_count = fuzzy.FuzzyInteger(0, 9999999999) condition = "Uusi" kitchen_appliances = fuzzy.FuzzyText() has_yard = True has_terrace = True has_balcony = True balcony_description = fuzzy.FuzzyText() bathroom_appliances = fuzzy.FuzzyText() storage_description = fuzzy.FuzzyText() has_apartment_sauna = True apartment_holding_type = "RIGHT_OF_RESIDENCE_APARTMENT" view_description = fuzzy.FuzzyText() sales_price = fuzzy.FuzzyInteger(0, 9999999999) debt_free_sales_price = fuzzy.FuzzyInteger(0, 9999999999) loan_share = fuzzy.FuzzyInteger(0, 9999999999) price_m2 = fuzzy.FuzzyInteger(0, 9999999999) housing_company_fee = fuzzy.FuzzyInteger(0, 9999999999) financing_fee = fuzzy.FuzzyInteger(0, 9999999999) financing_fee_m2 = fuzzy.FuzzyInteger(0, 9999999999) maintenance_fee = fuzzy.FuzzyInteger(0, 9999999999) maintenance_fee_m2 = fuzzy.FuzzyInteger(0, 9999999999) water_fee = fuzzy.FuzzyInteger(0, 9999999999) water_fee_explanation = fuzzy.FuzzyText() parking_fee = fuzzy.FuzzyInteger(0, 9999999999) parking_fee_explanation = fuzzy.FuzzyText() other_fees = fuzzy.FuzzyText() services_description = fuzzy.FuzzyText() additional_information = fuzzy.FuzzyText() application_url = fuzzy.FuzzyText() image_urls = factory.List([fuzzy.FuzzyText() for _ in range(2)])
def get_point_in_amsterdam(): lat = fuzzy.FuzzyFloat(*AMSTERDAM_LATITUDE).fuzz() lon = fuzzy.FuzzyFloat(*AMSTERDAM_LONGITUDE).fuzz() return Point(float(lat), float(lon))
def get_puntje(): lat = fuzzy.FuzzyFloat(BBOX[0], BBOX[2]).fuzz() lon = fuzzy.FuzzyFloat(BBOX[1], BBOX[3]).fuzz() return Point(float(lat), float(lon))
class CarFactory(factory.DjangoModelFactory): REGIONAL_PREFIXES = ('AA', 'KA', 'AB', 'KB', 'AC', 'KC', 'AE', 'KE', 'AH', 'KH', 'AI', 'KI', 'AK', 'KK', 'AM', 'KM', 'AO', 'KO', 'AP', 'KP', 'AT', 'KT', 'AX', 'KX', 'BA', 'HA', 'BB', 'HB', 'BC', 'HC', 'BE', 'HE', 'BH', 'HH', 'BI', 'HI', 'BK', 'HK', 'BM', 'HM', 'BO', 'HO', 'BP', 'HP', 'BT', 'HT', 'BX', 'HX', 'CA', 'IA', 'CB', 'IB', 'CC', 'IC', 'CE', 'IE', 'CH', 'IH', 'II') COLORS = ('white', 'black', 'silver', 'gray', 'brown', 'red', 'blue', 'green') MODELS = { 'Peugeot': ('108', '208', '301', '308', '408', '508', 'Bipper', 'Partner', 'Expert', 'Boxer'), 'Citroen': ('C1', 'C3', 'C4', 'C5', 'DS 3', 'DS 4', 'DS 4S', 'DS 5', 'Berlingo', 'Jumper', 'Jumpy', 'Nemo'), 'Suzuki': ('Alto', 'Baleno', 'Celerio', 'Lapin', 'Spacia', 'Swift', 'Carry', 'Jimny', 'Vitara', 'Every', 'Landy'), 'Fiat': ('Panda', '500', 'Uno', 'Linea', 'Tipo', 'Doblò', 'Ducato', 'Fiorino', 'Qubo', 'Talento'), 'Honda': ('Accord', 'Civic', 'Jazz', 'Insight', 'Inspire', 'Legend', 'Acty', 'Ridgeline', 'CR-V', 'HR-V', 'Acty', 'Freed', 'Odyssey'), 'Ford': ('C-Max', 'Fiesta', 'Figo', 'Fusion', 'Mondeo', 'Focus', 'Ka', 'Ranger', 'Super Duty', 'Galaxy', 'S-Max', 'Transit'), 'Hyundai': ('i10', 'i20', 'i30', 'Elantra', 'i40', 'Accent', 'Atos', 'Visto' 'Elantra', 'Eon', 'ix20', 'Cargo Truck', 'Porter', 'Xcient'), 'Kia': ('Ceed', 'Cerato', 'Optima', 'Picanto', 'Quoris', 'Ray', 'Stinger', 'Carens', 'Carnival', 'Venga', 'Besta', 'Bongo'), 'Renault': ('Clio', 'Fluence', 'Mégane', 'Talisman', 'Twingo', 'Scénic', 'Captur', 'Espace', 'Kadjar', 'Kangoo', 'Trafic'), 'Dacia': ('Logan', 'Sandero', 'Lodgy', 'Duster', 'Lodgy', 'Dokker'), 'Nissan': ('Altima', 'Cima', 'Fuga', 'Almera', 'Leaf', 'Micra', 'Navara', 'Patrol', 'Juke', 'Murano', 'Pathfinder', 'Clipper', 'Cabstar', 'Atlas'), 'Toyota': ('Auris', 'Aygo', 'Camry', 'Corolla', 'Prius', 'Yaris', 'Hilux', 'Land Cruiser', 'C-HR', 'RAV4', 'Avanza', 'Esquire', 'Estima', 'Innova', 'Pixis', 'Sienna', 'Dyna', 'ToyoAce'), 'SEAT': ('Toledo', 'Ibiza', 'León', 'Mii', 'Alhambra', 'Arona', 'Ateca'), 'Škoda': ('Citigo', 'Fabia', 'Octavia', 'Rapid', 'Superb', 'Kodiaq', 'Karoq'), 'Volkswagen': ('Bora', 'Fox', 'Golf', 'Jetta', 'Passat', 'Polo', 'Up', 'Vento', 'Voyage', 'T-Roc', 'Tiguan', 'Touareg', 'Caddy', 'Sharan', 'Suran', 'Touran', 'Amarok', 'Saveiro', 'Transporter', 'Crafter'), } mileage_unit = fuzzy.FuzzyChoice(k for k, _ in Car.UNITS) fuel_consumption = fuzzy.FuzzyFloat(3, 10) class Meta: model = Car exclude = ('REGIONAL_PREFIXES', 'COLORS', 'MODELS') @factory.lazy_attribute def plates(self): return '{regional_prefix}{four_digits}{two_letters}'.format( regional_prefix=random.choice(self.REGIONAL_PREFIXES), four_digits=''.join(random.choices(string.digits, k=4)), two_letters=''.join(random.choices('ABEIKMHOPCTX', k=2)), ) @factory.lazy_attribute def description(self): manufacturer = random.choice(list(self.MODELS.keys())) return '{color} {manufacturer} {model} {year}'.format( color=random.choice(self.COLORS).capitalize(), manufacturer=manufacturer, model=random.choice(self.MODELS[manufacturer]), year=random.randrange(1990, now().year), )
def get_random_coordinates(): coord_generator = fuzzy.FuzzyFloat(-180.0, 180.0) return [coord_generator.fuzz(), coord_generator.fuzz()]