Beispiel #1
0
class FieldReportFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = models.FieldReport

    is_covid_report = fuzzy.FuzzyChoice([True, False])
    rid = fuzzy.FuzzyText(length=100)
    dtype = factory.SubFactory(disaster_type.DisasterTypeFactory)
    event = factory.SubFactory(event.EventFactory)
    summary = fuzzy.FuzzyText(length=500)
    description = fuzzy.FuzzyText(length=200)
    report_date = fuzzy.FuzzyDateTime(
        datetime.datetime(2008, 1, 1, tzinfo=pytz.utc))
    # start_date is now what the user explicitly sets while filling the Field Report form.
    start_date = fuzzy.FuzzyDateTime(
        datetime.datetime(2008, 1, 1, tzinfo=pytz.utc))
    created_at = fuzzy.FuzzyDateTime(
        datetime.datetime(2008, 1, 1, tzinfo=pytz.utc))
    updated_at = fuzzy.FuzzyDateTime(
        datetime.datetime(2008, 1, 1, tzinfo=pytz.utc))
    previous_update = fuzzy.FuzzyDateTime(
        datetime.datetime(2008, 1, 1, tzinfo=pytz.utc))
    status = fuzzy.FuzzyInteger(0)

    request_assistance = False  # fuzzy.FuzzyChoice([True, False])
    ns_request_assistance = False  # fuzzy.FuzzyChoice([True, False])

    num_injured = fuzzy.FuzzyInteger(0, 9)
    num_dead = fuzzy.FuzzyInteger(0, 9)
    num_missing = fuzzy.FuzzyInteger(0, 9)
    num_affected = fuzzy.FuzzyInteger(0, 9)
    num_displaced = fuzzy.FuzzyInteger(0, 9)
    num_assisted = fuzzy.FuzzyInteger(0, 9)
    num_localstaff = fuzzy.FuzzyInteger(0, 9)
    num_volunteers = fuzzy.FuzzyInteger(0, 9)
    num_expats_delegates = fuzzy.FuzzyInteger(0, 9)

    # Early Warning fields
    num_potentially_affected = fuzzy.FuzzyInteger(0, 9)
    num_highest_risk = fuzzy.FuzzyInteger(0, 9)
    affected_pop_centres = fuzzy.FuzzyText(length=500)

    gov_num_injured = fuzzy.FuzzyInteger(0, 9)
    gov_num_dead = fuzzy.FuzzyInteger(0, 9)
    gov_num_missing = fuzzy.FuzzyInteger(0, 9)
    gov_num_affected = fuzzy.FuzzyInteger(0, 9)
    gov_num_displaced = fuzzy.FuzzyInteger(0, 9)
    gov_num_assisted = fuzzy.FuzzyInteger(0, 9)

    # Epidemic fields
    epi_cases = fuzzy.FuzzyInteger(0, 9)
    epi_suspected_cases = fuzzy.FuzzyInteger(0, 9)
    epi_probable_cases = fuzzy.FuzzyInteger(0, 9)
    epi_confirmed_cases = fuzzy.FuzzyInteger(0, 9)
    epi_num_dead = fuzzy.FuzzyInteger(0, 9)
    epi_figures_source = fuzzy.FuzzyChoice(models.EPISourceChoices)
    epi_cases_since_last_fr = fuzzy.FuzzyInteger(0, 9)
    epi_deaths_since_last_fr = fuzzy.FuzzyInteger(0, 9)
    epi_notes_since_last_fr = fuzzy.FuzzyText(length=50)

    who_num_assisted = fuzzy.FuzzyInteger(0, 9)
    health_min_num_assisted = fuzzy.FuzzyInteger(0, 9)

    # Early Warning fields
    gov_num_potentially_affected = fuzzy.FuzzyInteger(0, 9)
    gov_num_highest_risk = fuzzy.FuzzyInteger(0, 9)
    gov_affected_pop_centres = fuzzy.FuzzyText(length=500)

    other_num_injured = fuzzy.FuzzyInteger(0, 9)
    other_num_dead = fuzzy.FuzzyInteger(0, 9)
    other_num_missing = fuzzy.FuzzyInteger(0, 9)
    other_num_affected = fuzzy.FuzzyInteger(0, 9)
    other_num_displaced = fuzzy.FuzzyInteger(0, 9)
    other_num_assisted = fuzzy.FuzzyInteger(0, 9)

    # Early Warning fields
    other_num_potentially_affected = fuzzy.FuzzyInteger(0, 9)
    other_num_highest_risk = fuzzy.FuzzyInteger(0, 9)
    other_affected_pop_centres = fuzzy.FuzzyText(length=500)

    # Date of data for situation fields
    sit_fields_date = fuzzy.FuzzyDateTime(
        datetime.datetime(2008, 1, 1, tzinfo=pytz.utc))

    # Text field for users to specify sources for where they have marked 'Other' as source.
    other_sources = fuzzy.FuzzyText(length=50)

    # actions taken
    actions_others = fuzzy.FuzzyText(length=50)

    # visibility
    visibility = fuzzy.FuzzyChoice(models.VisibilityChoices)

    # information
    bulletin = fuzzy.FuzzyChoice(models.RequestChoices)
    dref = fuzzy.FuzzyChoice(models.RequestChoices)
    dref_amount = fuzzy.FuzzyInteger(0, 9999)
    appeal = fuzzy.FuzzyChoice(models.RequestChoices)
    appeal_amount = fuzzy.FuzzyInteger(0, 9999)
    imminent_dref = fuzzy.FuzzyChoice(models.RequestChoices)
    imminent_dref_amount = fuzzy.FuzzyInteger(0, 9999)
    forecast_based_action = fuzzy.FuzzyChoice(models.RequestChoices)  # only EW
    forecast_based_action_amount = fuzzy.FuzzyInteger(0, 9999)  # only EW

    # disaster response
    rdrt = fuzzy.FuzzyChoice(models.RequestChoices)
    num_rdrt = fuzzy.FuzzyInteger(0, 9)
    fact = fuzzy.FuzzyChoice(models.RequestChoices)
    num_fact = fuzzy.FuzzyInteger(0, 9)
    ifrc_staff = fuzzy.FuzzyChoice(models.RequestChoices)
    num_ifrc_staff = fuzzy.FuzzyInteger(0, 9)

    # ERU units
    eru_base_camp = fuzzy.FuzzyChoice(models.RequestChoices)
    eru_base_camp_units = fuzzy.FuzzyInteger(0, 9)

    eru_basic_health_care = fuzzy.FuzzyChoice(models.RequestChoices)
    eru_basic_health_care_units = fuzzy.FuzzyInteger(0, 9)

    eru_it_telecom = fuzzy.FuzzyChoice(models.RequestChoices)
    eru_it_telecom_units = fuzzy.FuzzyInteger(0, 9)

    eru_logistics = fuzzy.FuzzyChoice(models.RequestChoices)
    eru_logistics_units = fuzzy.FuzzyInteger(0, 9)

    eru_deployment_hospital = fuzzy.FuzzyChoice(models.RequestChoices)
    eru_deployment_hospital_units = fuzzy.FuzzyInteger(0, 9)

    eru_referral_hospital = fuzzy.FuzzyChoice(models.RequestChoices)
    eru_referral_hospital_units = fuzzy.FuzzyInteger(0, 9)

    eru_relief = fuzzy.FuzzyChoice(models.RequestChoices)
    eru_relief_units = fuzzy.FuzzyInteger(0, 9)

    eru_water_sanitation_15 = fuzzy.FuzzyChoice(models.RequestChoices)
    eru_water_sanitation_15_units = fuzzy.FuzzyInteger(0, 9)

    eru_water_sanitation_40 = fuzzy.FuzzyChoice(models.RequestChoices)
    eru_water_sanitation_40_units = fuzzy.FuzzyInteger(0, 9)

    eru_water_sanitation_20 = fuzzy.FuzzyChoice(models.RequestChoices)
    eru_water_sanitation_20_units = fuzzy.FuzzyInteger(0, 9)

    notes_health = fuzzy.FuzzyText(length=50)
    notes_ns = fuzzy.FuzzyText(length=50)
    notes_socioeco = fuzzy.FuzzyText(length=50)
Beispiel #2
0
    class TagFactory(DjangoModelFactory):
        class Meta:
            model = Tag

        name = FacFaker('word', locale='zh_CN')
        owner = fuzzy.FuzzyChoice(User.objects.all())
Beispiel #3
0
 def test_unbiased(self):
     options = [1, 2, 3]
     d = fuzzy.FuzzyChoice(options)
     res = d.evaluate(2, None, False)
     self.assertIn(res, options)
Beispiel #4
0
    def handle(self, *args, **options):

        if options.get('purge'):

            if options.get('interactive'):  # pragma: no cover
                msg = "Are you sure to delete all data?"
                choice = input("%s (y/N): " % msg).strip().lower()
                if choice != 'y':
                    return

            # Deleting users only should be enough to delete all instances.
            get_user_model().objects.all().delete()
            BankAccount.objects.all().delete()
            BankTransactionTag.objects.all().delete()
            BankTransaction.objects.all().delete()
            BankTransactionScheduler.objects.all().delete()

            self.stdout.write('All data have been deleted.')
            return

        user = UserFactory(
            username=options.get('username'),
            password=options.get('password'),
            email=options.get('email'),
            user_permissions='admin',
        )

        bankaccount = BankAccountFactory(
            label=_('Current account'),
            balance=2000,
            balance_initial=150,
            currency=options.get('currency'),
            owners=[user],
        )

        tag_rent = BankTransactionTagFactory(name=_('Rent'), owner=user)
        tag_shopping = BankTransactionTagFactory(name=_('Shopping'),
                                                 owner=user)
        tag_car = BankTransactionTagFactory(name=_('Car'), owner=user)
        tag_tax = BankTransactionTagFactory(name=_('Tax'), owner=user)
        tag_restaurant = BankTransactionTagFactory(name=_('Restaurant'),
                                                   owner=user)

        today = datetime.date.today()

        BankTransactionSchedulerFactory(
            bankaccount=bankaccount,
            label=_("Rent"),
            amount=Decimal("-910"),
            date=datetime.date(today.year, today.month, 10),
            payment_method=BankTransaction.PAYMENT_METHOD_TRANSFER,
            tag=tag_rent,
            type=BankTransactionScheduler.TYPE_MONTHLY,
            recurrence=None,
        ).clone()

        BankTransactionSchedulerFactory(
            bankaccount=bankaccount,
            label=_("Council tax"),
            amount=Decimal("-99.89"),
            date=datetime.date(today.year, today.month, 15),
            payment_method=BankTransaction.PAYMENT_METHOD_TRANSFER,
            tag=tag_tax,
            type=BankTransactionScheduler.TYPE_MONTHLY,
            recurrence=10,
        ).clone()

        BankTransactionSchedulerFactory(
            bankaccount=bankaccount,
            label=_("Wages"),
            amount=Decimal("2615.78"),
            date=datetime.date(today.year, today.month, 5),
            payment_method=BankTransaction.PAYMENT_METHOD_TRANSFER,
            tag=None,
            type=BankTransactionScheduler.TYPE_MONTHLY,
            recurrence=None,
        ).clone()

        BankTransactionFactory(
            bankaccount=bankaccount,
            label=_("Internal transfer"),
            amount=Decimal("500"),
            date=today - relativedelta(months=1, day=28),
            reconciled=True,
            status=BankTransaction.STATUS_IGNORED,
            payment_method=BankTransaction.PAYMENT_METHOD_TRANSFER_INTERNAL,
            tag=None,
            memo="Ineed$",
        )

        BankTransactionFactory(
            bankaccount=bankaccount,
            label=_("Scratch ticket"),
            amount=Decimal("150"),
            date=today,
            reconciled=False,
            payment_method=BankTransaction.PAYMENT_METHOD_CASH,
            tag=None,
            memo="Hooray!",
        )

        BankTransactionFactory(
            bankaccount=bankaccount,
            label=_("New tires"),
            amount=Decimal("-189.59"),
            date=today - relativedelta(days=5),
            reconciled=True,
            payment_method=BankTransaction.PAYMENT_METHOD_CHECK,
            tag=tag_car,
            memo="Love my bike!",
        )

        BankTransactionFactory(
            bankaccount=bankaccount,
            label=_("Bad stuff"),
            amount=Decimal("-79.90"),
            date=datetime.date(today.year, today.month, 9),
            reconciled=True,
            payment_method=BankTransaction.PAYMENT_METHOD_CREDIT_CARD,
            tag=tag_shopping,
        )

        BankTransactionFactory(
            bankaccount=bankaccount,
            label=_("Refund"),
            amount=Decimal("49.59"),
            date=datetime.date(today.year, today.month, 15),
            reconciled=True,
            payment_method=BankTransaction.PAYMENT_METHOD_TRANSFER,
            tag=tag_shopping,
        )

        date_start = today + relativedelta(months=-1, day=15)
        date_end = today + relativedelta(months=1, day=15)
        date = date_start

        while date < date_end:

            if date <= today or date.day % 3 == 0:

                choice = [tag_shopping, tag_restaurant, None, None]
                tag = fuzzy.FuzzyChoice(choice).fuzz()

                BankTransactionFactory(
                    bankaccount=bankaccount,
                    label=tag.name if tag is not None else _('Something'),
                    amount=fuzzy.FuzzyDecimal(-100, -10),
                    date=date,
                    reconciled=date < today - relativedelta(days=-3),
                    status=BankTransaction.STATUS_ACTIVE,
                    tag=tag,
                )

            date += relativedelta(days=1)

        self.stdout.write("Data have been generated successfully.")
Beispiel #5
0
class LanguageFactory(factory.DjangoModelFactory):
    code = fuzzy.FuzzyChoice(choices=['en', 'fr', 'el', 'es'])

    class Meta:
        model = Language
Beispiel #6
0
 def test_unbiased(self):
     options = [1, 2, 3]
     d = fuzzy.FuzzyChoice(options)
     res = utils.evaluate_declaration(d)
     self.assertIn(res, options)
Beispiel #7
0
class PizzaFactory(DjangoModelFactory):

    size = fuzzy.FuzzyChoice(['fifty', 'thirty'])

    class Meta:
        model = Pizza
class IndividualFactory(BaseFactory):
    birth_year = fuzzy.FuzzyInteger(1800, 2100)
    center = factory.SubFactory(CenterFactory)
    gender = fuzzy.FuzzyChoice(["MALE", "FEMALE", "UNKNOWN"])
    species = fuzzy.FuzzyChoice(["HUMAN", "MOUSE"])
    identifier = fuzzy.FuzzyText(length=12, chars=string.hexdigits)
class SampleFactory(BaseFactory):
    disease = factory.SubFactory(DiseaseFactory)
    individual = factory.SubFactory(IndividualFactory)
    pdx_id = fuzzy.FuzzyText(length=12, chars=string.hexdigits)
    category = fuzzy.FuzzyChoice(["TUMOR", "NORMAL"])
    identifier = fuzzy.FuzzyText(length=12, chars=string.hexdigits)
class AssemblyFactory(BaseFactory):
    name = "GRCh37"
    reference_data = {}
    species = fuzzy.FuzzyChoice(["HUMAN", "MOUSE"])
class TechniqueFactory(BaseFactory):
    reference_data = factory.SubFactory(factory.DictFactory)
    name = fuzzy.FuzzyText(length=12, chars=string.hexdigits)
    method = fuzzy.FuzzyChoice(
        choices=["CS", "TD", "WE", "WG", "MD", "TR", "WT"])
Beispiel #12
0
 def populate_recipes(number):
     for i in range(number):
         Progress.show_progress(i / number, 'Recipes')
         author = fuzzy.FuzzyChoice(User.objects.all())
         RecipeFactory.create(author=author, tags=Tag.objects.all())
     Progress.report_success(number, 'Recipes')
class WorkspaceFactory(factory.django.DjangoModelFactory):
    title = factory.Sequence(lambda n: "workspace_%d" % n)
    workspace_code = fuzzy.FuzzyChoice(COUNTRIES_LIST)

    class Meta:
        model = Workspace
class CountryFactory(factory.django.DjangoModelFactory):
    name = fuzzy.FuzzyChoice(COUNTRY_NAMES_LIST)

    class Meta:
        model = Country
Beispiel #15
0
class CarFactory(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")
        django_get_or_create = ("plates", )

    @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),
        )
Beispiel #16
0
class FakeBadgeFactory(django.DjangoModelFactory):
    code = fuzzy.FuzzyChoice(dict(settings.BADGE_CODE_CHOICES).keys())

    class Meta:
        model = Badge
Beispiel #17
0
import factory
from factory import fuzzy, django
from faker import Factory as FakerFactory

from django.contrib.auth import get_user_model
from django.contrib.auth.models import Group
from django.utils.timezone import now

from ..models.mixins import UserProfileMixin
from ..models import SocialNetwork
from ..conf import settings

faker = FakerFactory.create(getattr(settings, 'FAKER_SETTINGS_LOCALE',
                                    'en_GB'))

random_group = fuzzy.FuzzyChoice(Group.objects.all())


def fake_random_group():
    return random_group.fuzz()


class FakeUserProfileMixinFactory(django.DjangoModelFactory):
    class Meta:
        model = UserProfileMixin

    about_me = factory.LazyAttribute(lambda x: faker.text())
    bio_me = factory.LazyAttribute(lambda x: faker.text())
    short_me = factory.LazyAttribute(lambda x: faker.text())
    location = factory.LazyAttribute(
        lambda x: '{}, {}'.format(faker.city(), faker.country()))
Beispiel #18
0
class PlannedInterventionFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = PlannedIntervention

    title = fuzzy.FuzzyChoice(PlannedIntervention.Title)
Beispiel #19
0
def from_choices(field_cls):
    return fuzzy.FuzzyChoice([c[0] for c in field_cls.choices])
Beispiel #20
0
class IdentifiedNeedFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = IdentifiedNeed

    title = fuzzy.FuzzyChoice(IdentifiedNeed.Title)
Beispiel #21
0
class FeatureFactory(DjangoModelFactory):
    title = factory.PostGeneration(lambda feature, *args, **kwargs: f'Feature {feature.key}')
    feature_type = fuzzy.FuzzyChoice(Feature.FeatureType.choices, getter=lambda c: c[0])

    class Meta:
        model = Feature
Beispiel #22
0
class NationalSocietyActionFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = NationalSocietyAction

    title = fuzzy.FuzzyChoice(NationalSocietyAction.Title)
Beispiel #23
0
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),
        )
class FactoryRoleFactory(django.DjangoModelFactory):
    class Meta:
        model = Role

    status = fuzzy.FuzzyChoice(dict(settings.RELATION_ROLE_CH_STATUS).keys())
Beispiel #25
0
class CourseFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = Course

    title = fuzzy.FuzzyChoice(NAME_CHOICES)
    description = fuzzy.FuzzyText(length=256)
class PublishedAwardFinancialAssistanceFactory(factory.Factory):
    class Meta:
        model = stagingModels.PublishedAwardFinancialAssistance

    published_award_financial_assistance_id = None
    afa_generated_unique = fuzzy.FuzzyText()
    action_date = fuzzy.FuzzyDate(date(2015, 1, 1), date(2015, 12, 31))
    action_type = fuzzy.FuzzyText()
    assistance_type = fuzzy.FuzzyText()
    award_description = fuzzy.FuzzyText()
    awardee_or_recipient_legal = fuzzy.FuzzyText()
    awardee_or_recipient_uniqu = fuzzy.FuzzyText()
    awarding_agency_code = fuzzy.FuzzyText()
    awarding_agency_name = fuzzy.FuzzyText()
    awarding_office_code = fuzzy.FuzzyText()
    awarding_office_name = fuzzy.FuzzyText()
    awarding_sub_tier_agency_c = fuzzy.FuzzyText()
    awarding_sub_tier_agency_n = fuzzy.FuzzyText()
    award_modification_amendme = fuzzy.FuzzyText()
    business_funds_indicator = fuzzy.FuzzyText()
    business_types = fuzzy.FuzzyText()
    cfda_number = fuzzy.FuzzyText()
    cfda_title = fuzzy.FuzzyText()
    correction_late_delete_ind = fuzzy.FuzzyText()
    face_value_loan_guarantee = fuzzy.FuzzyDecimal(9999)
    fain = fuzzy.FuzzyText()
    federal_action_obligation = fuzzy.FuzzyDecimal(9999)
    fiscal_year_and_quarter_co = fuzzy.FuzzyText()
    funding_agency_code = fuzzy.FuzzyText()
    funding_agency_name = fuzzy.FuzzyText()
    funding_office_code = fuzzy.FuzzyText()
    funding_office_name = fuzzy.FuzzyText()
    funding_sub_tier_agency_co = fuzzy.FuzzyText()
    funding_sub_tier_agency_na = fuzzy.FuzzyText()
    is_historical = fuzzy.FuzzyChoice([True, False])
    legal_entity_address_line1 = fuzzy.FuzzyText()
    legal_entity_address_line2 = fuzzy.FuzzyText()
    legal_entity_address_line3 = fuzzy.FuzzyText()
    legal_entity_city_name = fuzzy.FuzzyText()
    legal_entity_city_code = fuzzy.FuzzyText()
    legal_entity_country_code = fuzzy.FuzzyText()
    legal_entity_country_name = fuzzy.FuzzyText()
    legal_entity_county_code = fuzzy.FuzzyText()
    legal_entity_county_name = fuzzy.FuzzyText()
    legal_entity_foreign_city = fuzzy.FuzzyText()
    legal_entity_foreign_posta = fuzzy.FuzzyText()
    legal_entity_foreign_provi = fuzzy.FuzzyText()
    legal_entity_congressional = fuzzy.FuzzyText()
    legal_entity_state_code = fuzzy.FuzzyText()
    legal_entity_state_name = fuzzy.FuzzyText()
    legal_entity_zip5 = fuzzy.FuzzyText()
    legal_entity_zip_last4 = fuzzy.FuzzyText()
    non_federal_funding_amount = fuzzy.FuzzyDecimal(9999)
    original_loan_subsidy_cost = fuzzy.FuzzyDecimal(9999)
    total_funding_amount = fuzzy.FuzzyDecimal(9999)
    period_of_performance_curr = fuzzy.FuzzyDate(date(2015, 1, 1),
                                                 date(2015, 12, 31))
    period_of_performance_star = fuzzy.FuzzyDate(date(2015, 1, 1),
                                                 date(2015, 12, 31))
    place_of_performance_code = fuzzy.FuzzyText()
    place_of_performance_congr = fuzzy.FuzzyText()
    place_of_perform_country_c = fuzzy.FuzzyText()
    place_of_perform_country_n = fuzzy.FuzzyText()
    place_of_perform_county_co = fuzzy.FuzzyText()
    place_of_perform_state_nam = fuzzy.FuzzyText()
    place_of_perform_county_na = fuzzy.FuzzyText()
    place_of_performance_city = fuzzy.FuzzyText()
    place_of_performance_forei = fuzzy.FuzzyText()
    place_of_performance_zip4a = fuzzy.FuzzyText()
    record_type = fuzzy.FuzzyInteger(1, 2)
    sai_number = fuzzy.FuzzyText()
    uri = fuzzy.FuzzyText()
    modified_at = fuzzy.FuzzyDate(date(2015, 1, 1), date(2015, 12, 31))
Beispiel #27
0
class LanguageFactory(factory.DjangoModelFactory):
    FACTORY_FOR = Language
    code = fuzzy.FuzzyChoice(choices=['en', 'fr', 'el', 'es'])
Beispiel #28
0
class ProviderFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = 'testapp.Provider'

    name = factory.Faker('company')
    score = fuzzy.FuzzyChoice('ABCDEF')
Beispiel #29
0
class CellAreaKeyFactory(Factory):

    radio = fuzzy.FuzzyChoice([Radio.gsm, Radio.wcdma, Radio.lte])
    mcc = GB_MCC
    mnc = GB_MNC
    lac = fuzzy.FuzzyInteger(1, 60000)
Beispiel #30
0
 def test_getter(self):
     options = [('a', 1), ('b', 2), ('c', 3)]
     d = fuzzy.FuzzyChoice(options, getter=lambda x: x[1])
     res = utils.evaluate_declaration(d)
     self.assertIn(res, [1, 2, 3])