Exemple #1
0
class PassageFactory(DjangoModelFactory):
    class Meta:
        model = Passage

    passage_id = factory.Faker('uuid4')
    version = "passage-v1"
    passage_at = factory.LazyFunction(timezone.now)
    straat = factory.Faker('name')
    rijstrook = fuzzy.FuzzyInteger(1, 10)
    rijrichting = fuzzy.FuzzyChoice((-1, 1))
    camera_id = factory.Faker('uuid4')
    camera_naam = factory.Faker('name')
    camera_kijkrichting = fuzzy.FuzzyInteger(0, 400)
    camera_locatie = factory.LazyFunction(get_point_in_amsterdam)
    kenteken_land = fuzzy.FuzzyText(length=2)
    kenteken_nummer_betrouwbaarheid = fuzzy.FuzzyInteger(1, 1000)
    kenteken_land_betrouwbaarheid = fuzzy.FuzzyInteger(1.0, 1000.0, 1)
    kenteken_karakters_betrouwbaarheid = factory.LazyFunction(
        kenteken_karakter_betrouwbaarheid
    )
    indicatie_snelheid = fuzzy.FuzzyFloat(0, 500)
    automatisch_verwerkbaar = factory.Faker('boolean', chance_of_getting_true=50)
    voertuig_soort = fuzzy.FuzzyChoice(VOERTUIG_SOORTEN)
    merk = factory.Faker('first_name')
    inrichting = factory.Faker('first_name')
    datum_eerste_toelating = fuzzy.FuzzyDate(datetime.date(2008, 1, 1))
    datum_tenaamstelling = fuzzy.FuzzyDate(datetime.date(2008, 1, 1))
    toegestane_maximum_massa_voertuig = fuzzy.FuzzyInteger(1, 32000)
    europese_voertuigcategorie = fuzzy.FuzzyText(length=2)
    europese_voertuigcategorie_toevoeging = fuzzy.FuzzyText(length=1)
    taxi_indicator = factory.Faker('boolean', chance_of_getting_true=50)
    maximale_constructie_snelheid_bromsnorfiets = fuzzy.FuzzyInteger(0, 500)
    brandstoffen = factory.LazyFunction(get_brandstoffen_v1)
Exemple #2
0
class FundsReservationHeaderFactory(factory.DjangoModelFactory):
    class Meta:
        model = models.FundsReservationHeader

    intervention = factory.SubFactory(InterventionFactory)
    vendor_code = fuzzy.FuzzyText(length=20)
    fr_number = fuzzy.FuzzyText(length=20)
    document_date = datetime.date(datetime.date.today().year, 1, 1)
    fr_type = fuzzy.FuzzyText(length=20)
    currency = fuzzy.FuzzyText(length=20)
    document_text = fuzzy.FuzzyText(length=20)

    # this is the field required for validation
    intervention_amt = fuzzy.FuzzyDecimal(1, 300)
    # overall_amount
    total_amt = fuzzy.FuzzyDecimal(1, 300)
    actual_amt = fuzzy.FuzzyDecimal(1, 300)
    outstanding_amt = fuzzy.FuzzyDecimal(1, 300)

    total_amt_local = fuzzy.FuzzyDecimal(1, 300)
    actual_amt_local = fuzzy.FuzzyDecimal(1, 300)
    outstanding_amt_local = fuzzy.FuzzyDecimal(1, 300)

    start_date = fuzzy.FuzzyDate(
        datetime.date(datetime.date.today().year, 1, 1) - datetime.timedelta(days=10),
        datetime.date(datetime.date.today().year, 1, 1)
    )
    end_date = fuzzy.FuzzyDate(
        datetime.date(datetime.date.today().year + 1, 1, 1),
        datetime.date(datetime.date.today().year + 1, 1, 1) + datetime.timedelta(days=10)
    )
class DunsFactory(factory.Factory):
    class Meta:
        model = domainModels.DUNS

    duns_id = None
    awardee_or_recipient_uniqu = fuzzy.FuzzyText()
    legal_business_name = fuzzy.FuzzyText()
    dba_name = fuzzy.FuzzyText()
    activation_date = fuzzy.FuzzyDate(date(2000, 1, 1), date(2020, 12, 31))
    deactivation_date = fuzzy.FuzzyDate(date(2000, 1, 1), date(2020, 12, 31))
    registration_date = fuzzy.FuzzyDate(date(2000, 1, 1), date(2020, 12, 31))
    expiration_date = fuzzy.FuzzyDate(date(2000, 1, 1), date(2020, 12, 31))
    last_sam_mod_date = fuzzy.FuzzyDate(date(2000, 1, 1), date(2020, 12, 31))
    address_line_1 = fuzzy.FuzzyText()
    address_line_2 = fuzzy.FuzzyText()
    city = fuzzy.FuzzyText()
    state = fuzzy.FuzzyText()
    zip = fuzzy.FuzzyText()
    zip4 = fuzzy.FuzzyText()
    country_code = fuzzy.FuzzyText()
    congressional_district = fuzzy.FuzzyText()
    entity_structure = fuzzy.FuzzyText()
    business_types_codes = ['A', 'B', 'C']
    ultimate_parent_unique_ide = fuzzy.FuzzyText()
    ultimate_parent_legal_enti = fuzzy.FuzzyText()
Exemple #4
0
class ReportingRequirementFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = models.ReportingRequirement

    report_type = fuzzy.FuzzyChoice(models.ReportingRequirement.TYPE_CHOICES)
    end_date = fuzzy.FuzzyDate(datetime.date(2001, 1, 1))
    due_date = fuzzy.FuzzyDate(datetime.date(2001, 1, 1))
Exemple #5
0
class ConferenceFactory(DjangoModelFactory):
    title = fuzzy.FuzzyText()
    start_date = fuzzy.FuzzyDate(datetime.date(2014, 1, 1))
    end_date = fuzzy.FuzzyDate(
        datetime.date(2014, 1, 1) +
        datetime.timedelta(days=random.randint(1, 10)))

    class Meta:
        model = Conference
Exemple #6
0
 class Params:
     starts_in_future = factory.Trait(date_start=fuzzy.FuzzyDate(
         start_date=timezone.now(),
         end_date=timezone.now() + timezone.timedelta(days=30),
     ))
     starts_in_past = factory.Trait(date_start=fuzzy.FuzzyDate(
         start_date=timezone.now() - timezone.timedelta(weeks=12),
         end_date=timezone.now() - timezone.timedelta(days=1),
     ), )
Exemple #7
0
class ConferenceFactory(factory.DjangoModelFactory):
    title = fuzzy.FuzzyText()
    start_date = fuzzy.FuzzyDate(datetime.date(2014, 1, 1))
    end_date = fuzzy.FuzzyDate(datetime.date(2014, 1, 1)
                               + datetime.timedelta(days=random.randint(1, 10)))
    # timezone = TimeZoneField("UTC")

    class Meta:
        model = Conference
Exemple #8
0
class ExchangeRateFactory(factory.DjangoModelFactory):
    valid_from = fuzzy.FuzzyDate(_FUZZY_START_DATE.date(),
                                 _FUZZY_END_DATE.date())
    valid_to = fuzzy.FuzzyDate(_FUZZY_START_DATE.date(),
                               _FUZZY_END_DATE.date())
    x_rate = fuzzy.FuzzyDecimal(0.5, 400)

    class Meta:
        model = models.ExchangeRate
class SubmissionWindowFactory(factory.Factory):
    class Meta:
        model = jobModels.SubmissionWindow

    window_id = fuzzy.FuzzyInteger(9999)
    start_date = fuzzy.FuzzyDate(date(2010, 1, 1))
    end_date = fuzzy.FuzzyDate(date(2010, 1, 1))
    block_certification = False
    message = fuzzy.FuzzyText()
    application_type = factory.SubFactory(ApplicationTypeFactory)
class TodoFactory(factory.alchemy.SQLAlchemyModelFactory):
    class Meta:
        model = TodoModel
        sqlalchemy_session = db.session

    title = factory.Faker('sentence')
    description = factory.Faker('text')
    from_date = fuzzy.FuzzyDate(datetime.date(2008, 1, 1))
    to_date = fuzzy.FuzzyDate(datetime.date(2018, 1, 1))
    completed = factory.LazyFunction(lambda: random.choice([True, False]))
Exemple #11
0
class MembershipFactory(factory.DjangoModelFactory):
    class Meta:
        model = models.Membership

    participant = factory.SubFactory(ParticipantFactory)
    tier = factory.SubFactory(TierFactory)
    effective_from = fuzzy.FuzzyDate(start_date=(timezone.now() -
                                                 timedelta(days=30)).date())
    form_filled = fuzzy.FuzzyDate(start_date=(timezone.now() -
                                              timedelta(days=30)).date())
Exemple #12
0
class ParticipantFactory(factory.DjangoModelFactory):
    class Meta:
        model = models.Participant

    name = fuzzy.FuzzyText()
    surname = fuzzy.FuzzyText()
    date_of_birth = fuzzy.FuzzyDate(start_date=(timezone.now() -
                                                timedelta(days=36500)).date())
    participation_form_filled_on = fuzzy.FuzzyDate(
        start_date=(timezone.now() - timedelta(days=365)).date())
class FileGenerationFactory(factory.Factory):
    class Meta:
        model = jobModels.FileGeneration

    file_generation_id = fuzzy.FuzzyInteger(9999)
    request_date = fuzzy.FuzzyDate(date(2010, 1, 1))
    start_date = fuzzy.FuzzyDate(date(2010, 1, 1))
    end_date = fuzzy.FuzzyDate(date(2010, 1, 1))
    agency_code = fuzzy.FuzzyText()
    agency_type = fuzzy.FuzzyChoice({'awarding', 'funding'})
    file_type = fuzzy.FuzzyChoice({'D1', 'D2'})
    file_path = fuzzy.FuzzyText()
    is_cached_file = fuzzy.FuzzyChoice((False, True))
class DunsFactory(factory.Factory):
    class Meta:
        model = domainModels.DUNS

    duns_id = None
    awardee_or_recipient_uniqu = fuzzy.FuzzyText()
    legal_business_name = fuzzy.FuzzyText()
    activation_date = fuzzy.FuzzyDate(date(2000, 1, 1), date(2020, 12, 31))
    deactivation_date = fuzzy.FuzzyDate(date(2000, 1, 1), date(2020, 12, 31))
    registration_date = fuzzy.FuzzyDate(date(2000, 1, 1), date(2020, 12, 31))
    expiration_date = fuzzy.FuzzyDate(date(2000, 1, 1), date(2020, 12, 31))
    last_sam_mod_date = fuzzy.FuzzyDate(date(2000, 1, 1), date(2020, 12, 31))
    ultimate_parent_unique_ide = fuzzy.FuzzyText()
    ultimate_parent_legal_enti = fuzzy.FuzzyText()
Exemple #15
0
class PublicsCountryFactory(factory.DjangoModelFactory):
    name = fuzzy.FuzzyText(length=32)
    long_name = fuzzy.FuzzyText(length=32)
    iso_2 = fuzzy.FuzzyText(length=2)
    iso_3 = fuzzy.FuzzyText(length=3)
    valid_from = fuzzy.FuzzyDate(_FUZZY_START_DATE.date(),
                                 _FUZZY_END_DATE.date())
    valid_to = fuzzy.FuzzyDate(_FUZZY_START_DATE.date(),
                               _FUZZY_END_DATE.date())
    business_area = factory.SubFactory(PublicsBusinessAreaFactory)
    currency = factory.SubFactory(PublicsCurrencyFactory)

    class Meta:
        model = models.Country
Exemple #16
0
class FileRequestFactory(factory.Factory):
    class Meta:
        model = jobModels.FileRequest

    file_request_id = fuzzy.FuzzyInteger(9999)
    request_date = fuzzy.FuzzyDate(date(2010, 1, 1))
    job_id = fuzzy.FuzzyInteger(9999)
    job = factory.SubFactory(JobFactory)
    parent_job_id = fuzzy.FuzzyInteger(9999)
    start_date = fuzzy.FuzzyDate(date(2010, 1, 1))
    end_date = fuzzy.FuzzyDate(date(2010, 1, 1))
    agency_code = fuzzy.FuzzyText()
    file_type = fuzzy.FuzzyText()
    is_cached_file = fuzzy.FuzzyChoice((False, True))
Exemple #17
0
class SubmissionFactory(factory.Factory):
    class Meta:
        model = jobModels.Submission

    submission_id = None
    user_id = None
    cgac_code = fuzzy.FuzzyText()
    reporting_start_date = fuzzy.FuzzyDate(date(2010, 1, 1))
    reporting_end_date = fuzzy.FuzzyDate(date(2010, 1, 1))
    reporting_fiscal_year = fuzzy.FuzzyInteger(2010, 2040)
    reporting_fiscal_period = fuzzy.FuzzyInteger(1, 4)
    is_quarter_format = False
    publishable = False
    number_of_errors = 0
    number_of_warnings = 0
class FSRSSubgrantFactory(factory.Factory, _GrantAttributes):
    class Meta:
        model = fsrs.FSRSSubgrant

    subaward_amount = fuzzy.FuzzyText()
    subaward_date = fuzzy.FuzzyDate(date(2010, 1, 1))
    subaward_num = fuzzy.FuzzyText()
Exemple #19
0
class FSRSGrantFactory(_GrantAttributes, _PrimeAwardAttributes):
    class Meta:
        model = fsrs.FSRSGrant

    fain = fuzzy.FuzzyText()
    total_fed_funding_amount = fuzzy.FuzzyText()
    obligation_date = fuzzy.FuzzyDate(date(2010, 1, 1))
Exemple #20
0
class WineFactory(factory.django.DjangoModelFactory):
    FACTORY_FOR = Wine
    wineType = 'w'
    name = u'test'
    # cepage = factory.SubFactory(CepageFactory)
    appelation = factory.SubFactory(AppelationFactory)
    country = factory.SubFactory(CountryFactory)
    producer = factory.SubFactory(ProducerFactory)
    region = factory.SubFactory(RegionFactory)
    # tag = factory.SubFactory(TagFactory)
    teint = factory.SubFactory(TeintFactory)
    # slug = u'slug-a'
    date = fuzzy.FuzzyDate(datetime(2005, 1, 1).date())
    alcool = fuzzy.FuzzyDecimal(1, 100)
    price = fuzzy.FuzzyDecimal(1, 1000)
    year = 2009
    mouth_intensity = 0.5
    nose_intensity = 0.5
    rating = 0.5
    persistance = 0.5
    aroma = factory.SubFactory(AromaFactory)
    taste = factory.SubFactory(TasteFactory)
    acidity = factory.SubFactory(AcidityFactory)
    tanin = factory.SubFactory(TaninFactory)
    code_saq = fuzzy.FuzzyInteger(0, 10000000)
Exemple #21
0
class UserStatusFactory(factory.django.DjangoModelFactory):
    """Factory for UserStatus model."""
    FACTORY_FOR = UserStatus

    user = factory.SubFactory(UserFactory)
    expected_date = fuzzy.FuzzyDate(now().date() - datetime.timedelta(weeks=1),
                                    now().date() + datetime.timedelta(weeks=1))
Exemple #22
0
class CreditCard(factory.DictFactory):
    first_name = fuzzy.FuzzyText()
    last_name = fuzzy.FuzzyText()

    card_number = fuzzy.FuzzyChoice(choices=CARDS)
    expire_date = fuzzy.FuzzyDate(start_date=date.today())
    cvv = fuzzy.FuzzyText(length=3, chars='0123456789')
Exemple #23
0
    def test_action_point_added(self):
        visit = TPMVisitFactory(status='tpm_reported', tpm_activities__count=1)
        activity = visit.tpm_activities.first()
        self.assertEqual(activity.action_points.count(), 0)

        response = self.forced_auth_req(
            'post',
            '/api/tpm/visits/{}/action-points/'.format(visit.id),
            user=self.pme_user,
            data={
                'tpm_activity':
                activity.id,
                'description':
                fuzzy.FuzzyText(length=100).fuzz(),
                'due_date':
                fuzzy.FuzzyDate(timezone.now().date(), _FUZZY_END_DATE).fuzz(),
                'assigned_to':
                self.unicef_user.id,
                'office':
                self.pme_user.profile.office.id,
                'section':
                SectionFactory().id,
            })

        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
        self.assertEqual(activity.action_points.count(), 1)
        self.assertIsNotNone(activity.action_points.first().partner)
Exemple #24
0
class PlayerFactory(DjangoModelFactory):
    class Meta:
        model = Player

    player_id = FuzzyEntityIdentifier(model=Player, field='player_id')
    first_name = fuzzy.FuzzyText(length=100)
    last_name = fuzzy.FuzzyText(length=100)
    display_first_last = factory.LazyAttribute(
        lambda x: x.first_name + " " + x.last_name)
    display_last_comma_first = factory.LazyAttribute(
        lambda x: x.last_name + ", " + x.first_name)
    display_fi_last = factory.LazyAttribute(
        lambda x: x.first_name[0] + " " + x.last_name)
    birthdate = fuzzy.FuzzyDate(start_date=date(1920, 1, 1))
    height = fuzzy.FuzzyInteger(low=60, high=100)
    weight = fuzzy.FuzzyInteger(low=50, high=400)
    season_exp = fuzzy.FuzzyInteger(low=0, high=20)
    jersey = fuzzy.FuzzyChoice([str(x) for x in range(100)])
    position = fuzzy.FuzzyChoice([
        '', 'Center', 'Center-Forward', 'Forward', 'Forward-Center',
        'Forward-Guard', 'Guard', 'Guard-Forward', None
    ])
    rosterstatus = fuzzy.FuzzyChoice(['Active', 'Inactive', None])
    team = factory.SubFactory(Team)
    playercode = fuzzy.FuzzyText(length=35)
    from_year = fuzzy.FuzzyInteger(low=1995, high=2017)
    to_year = fuzzy.FuzzyInteger(low=1995, high=2017)
Exemple #25
0
class NGReportFactory(factory.django.DjangoModelFactory):

    user = factory.SubFactory(UserFactory, userprofile__initial_council=True)
    mentor = factory.SelfAttribute('user.userprofile.mentor')
    activity = factory.SubFactory(ActivityFactory)
    latitude = fuzzy.FuzzyDecimal(low=-90.0, high=90.0, precision=5)
    longitude = fuzzy.FuzzyDecimal(low=-180.0, high=180.0, precision=5)
    location = 'Activity Location'
    is_passive = False
    link = 'www.example.com'
    report_date = fuzzy.FuzzyDate(datetime.date(2013, 1, 1), now().date())

    class Meta:
        model = NGReport

    @factory.post_generation
    def functional_areas(self, create, extracted, **kwargs):
        """Add functional areas list after object generation."""
        if not create:
            return
        if extracted:
            for area in extracted:
                self.functional_areas.add(area)
        else:
            # create random
            rand_int = randint(1, 6)
            for area in (FunctionalArea.active_objects.all().order_by('?')
                         [:rand_int]):
                self.functional_areas.add(area)
Exemple #26
0
class EngagementActionPointFactory(factory.DjangoModelFactory):
    class Meta:
        model = EngagementActionPoint

    category = fuzzy.FuzzyChoice(EngagementActionPoint.CATEGORY_CHOICES)
    description = fuzzy.FuzzyText(length=100)
    due_date = fuzzy.FuzzyDate(datetime.date(2001, 1, 1))
Exemple #27
0
class MonumentenDataFactory(factory.DjangoModelFactory):
    class Meta(object):
        model = models.Monument

    if random.randint(0, 50) % 3 == 0:  # one in 3 is filled
        monument_aanwijzingsdatum = fuzzy.FuzzyDate(
            start_date=datetime.today() - timedelta(
                days=random.randint(10, 9000)), end_date=datetime.today())
    architect_ontwerp_monument = fuzzy.FuzzyText(length=128)
    if random.randint(0, 50) % 3 == 0:
        heeft_als_grondslag_beperking = fuzzy.FuzzyInteger(low=0)
    beschrijving_monument = fuzzy.FuzzyText()

    monumentcoordinaten = fuzzy.FuzzyInteger(low=1)
    oorspronkelijke_functie_monument = fuzzy.FuzzyText(length=128)
    in_onderzoek = fuzzy.FuzzyText(length=3)
    monumentnummer = factory.sequence(lambda n: n)
    monumentnaam = fuzzy.FuzzyText(length=255)
    opdrachtgever_bouw_monument = fuzzy.FuzzyText(length=128)
    if random.randint(0, 50) % 4:
        redengevende_omschrijving_monument = fuzzy.FuzzyText()
    if random.randint(0, 50) % 4:
        monumentstatus = fuzzy.FuzzyText(length=128)
    monumenttype = fuzzy.FuzzyText(length=128)
    betreft_pand = factory.RelatedFactory(PandrelatieDataFactory, 'monument')
class EarningsReportFactory(DjangoModelFactory):
    restaurant = SubFactory(RestaurantFactory)
    date = fuzzy.FuzzyDate(date(2000, 1, 1))
    amount = fuzzy.FuzzyDecimal(0, 10000)

    class Meta:
        model = EarningsReport
Exemple #29
0
class DriveFactory(factory.DjangoModelFactory):

    class Meta:
        model = Drive

    driver = factory.SubFactory(UserFactory)
    car = factory.SubFactory(CarFactory)
    date = fuzzy.FuzzyDate((now() - timedelta(days=1000)).date())
    start_mileage = fuzzy.FuzzyInteger(1000000)
    description = factory.Faker('text', max_nb_chars=1000)

    @factory.lazy_attribute
    def end_mileage(self):
        return random.randint(self.start_mileage, 1000000)

    @factory.post_generation
    def passengers(self, create, extracted, **kwargs):
        if not create:
            return

        if extracted:
            for passenger in extracted:
                self.passengers.add(passenger)

    @factory.post_generation
    def project_set(self, create, extracted, **kwargs):
        if not create:
            return

        if extracted:
            for project in extracted:
                self.project_set.add(project)
class NewsPageFactory(BasePageFactory):
    """Factory generating data for NewsPage."""
    class Meta:
        model = NewsPage

    date = fuzzy.FuzzyDate(
        start_date=timezone.now() - timezone.timedelta(weeks=520),
        end_date=timezone.now(),
    )
    feed_image = factory.SubFactory(ImageFactory)

    @factory.post_generation
    def news_categories(self, create, categories, **kwargs):
        """Generate M2M for news categories."""
        if not create:
            return

        if categories:
            for category in categories:
                self.news_categories.add(category)

    @factory.post_generation
    def related_news(self, create, articles, **kwargs):
        """Generate M2M for related news."""
        if not create:
            return

        if articles:
            for article in articles:
                self.related_news.add(article)