Пример #1
0
class RegistrationEventFactory(factory.django.DjangoModelFactory):
    name = factory.Sequence(lambda n: f'Test Registration Event {n}')
    league = factory.SubFactory(LeagueFactory)
    start_date = FuzzyDate(date(2000, 1, 1))
    end_date = FuzzyDate(date(2000, 12, 31))

    class Meta:
        model = 'registration.RegistrationEvent'
Пример #2
0
    def dicom_date(self):
        """Dicom date string. Like 20120425 (VR = DA)

        Returns
        -------
        str
        """
        date = FuzzyDate(start_date=datetime.date(2008, 1, 1),
                         end_date=datetime.date(2013, 4, 16)).fuzz()
        return date.strftime("%Y%m%d")
Пример #3
0
class ProfessionFactory(factory.Factory):
    des1_cargo = factory.Sequence(lambda n: 'Trabajo #{0}'.format(n))
    employer = FuzzyAttribute(lambda: 'Empresa #' + str(randint(0, 100)))
    f_toma_posesion = FuzzyDate(datetime.date(1940, 1, 1)).fuzz()
    f_hasta = FuzzyAttribute(
        lambda: random.choice([None, FuzzyDate(d).fuzz()]))
    centro = FuzzyAttribute(
        lambda: random.choice([None, 'Centro #' + str(randint(0, 100))]))
    des1_departamento = FuzzyAttribute(
        lambda: random.choice([None, 'Departamento #' + str(randint(0, 100))]))
    des1_dedicacion = FuzzyChoice([True, False, None])

    class Meta:
        model = dict
Пример #4
0
class WorkshopFactory(factory.DjangoModelFactory):
    class Meta:
        model = Workshop

    title = FuzzyText(length=50)
    location = FuzzyText(length=50)
    description = FuzzyText(length=50)
    start_date = FuzzyDate(datetime.date(2016, 1, 1),
                           datetime.date(2016, 12, 31))
    end_date = FuzzyDate(datetime.date(2017, 1, 1),
                         datetime.date(2017, 12, 31))
    url = factory.LazyAttribute(lambda o: '%s.com' % o.title)
    slug = factory.Sequence(lambda n: 'workshop%d' % n)
    draft = FuzzyChoice([True, False])
Пример #5
0
class UseOfForceIncidentLMPDFactory(BaseFactory):
    ''' Generate a fake LMPD uof incident. Must pass a department_id when using.
    '''
    opaque_id = FuzzyText(length=32)
    occured_date = FuzzyDate(datetime.date(2015, 1, 1))
    bureau = FuzzyText(length=16)
    division = FuzzyText(length=16)
    unit = FuzzyText(length=16)
    platoon = FuzzyText(length=16)
    disposition = FuzzyText(length=16)
    use_of_force_reason = FuzzyText(length=16)
    officer_force_type = FuzzyText(length=16)
    service_type = FuzzyText(length=16)
    arrest_made = FuzzyChoice([True, False])
    arrest_charges = FuzzyText(length=16)
    resident_injured = FuzzyChoice([True, False])
    resident_hospitalized = FuzzyChoice([True, False])
    resident_condition = FuzzyText(length=16)
    officer_injured = FuzzyChoice([True, False])
    officer_hospitalized = FuzzyChoice([True, False])
    officer_condition = FuzzyText(length=16)
    resident_identifier = FuzzyText(length=32)
    resident_weapon_used = FuzzyText(length=16)
    resident_race = FuzzyText(length=16)
    resident_sex = FuzzyText(length=16)
    resident_age = FuzzyText(length=16)
    officer_race = FuzzyText(length=16)
    officer_sex = FuzzyText(length=16)
    officer_age = FuzzyText(length=16)
    officer_years_of_service = FuzzyText(length=16)
    officer_identifier = FuzzyText(length=32)

    class Meta:
        model = UseOfForceIncidentLMPD
Пример #6
0
class AstroObjectFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = AstroObject

    type = FuzzyChoice(choices=[
        u'Asterism', u'Double Star', u'Galaxy', u'Globular Cluster', u'Nebula',
        u'Nebulosity in External Galaxy', u'Open Cluster', u'Planetary Nebula',
        u'Star', u'Supernova Remnant', u'Triple Star'
    ])
    index = factory.Sequence(lambda n: n)
    ra_hours = FuzzyFloat(0.0, 23.0)
    ra_minutes = FuzzyFloat(0.0, 59.0)
    ra_seconds = FuzzyFloat(0.0, 59.0)
    dec_sign = FuzzyChoice(choices=['+', '-'])
    dec_deg = FuzzyInteger(0, 89)
    dec_min = FuzzyFloat(0.0, 59.0)
    dec_seconds = FuzzyFloat(0.0, 59)
    magnitude = FuzzyFloat(-4.0, 14)
    size = FuzzyFloat(0.1, 10000.0)
    distance = FuzzyInteger(1, 1000000000)
    details = FuzzyText(length=40)
    description = FuzzyText(length=500)
    common_name = factory.Sequence(lambda n: "NGC{0}".format(n))
    points = FuzzyInteger(0, 100)
    image = None
    image_attribution = FuzzyText(length=50)
    discoverer = FuzzyText(length=20)
    discovery_date = FuzzyDate(start_date=datetime.date(1700, 1, 1))

    constellation = factory.SubFactory(ConstellationFactory)
Пример #7
0
class RegistrationDataFactoryMinimumFields(factory.django.DjangoModelFactory):
    invite = factory.SubFactory(RegistrationInviteFactory)
    user = factory.SubFactory(UserFactory)
    event = factory.SubFactory(RegistrationEventFactory)
    organization = factory.SubFactory(OrganizationFactory)

    contact_email = factory.SelfAttribute('user.email')
    contact_address1 = factory.Sequence(lambda n: f'{n} Test St')
    contact_address2 = factory.Sequence(lambda n: f'Apartment #{n}')
    contact_city = "Test City"
    contact_state = "WI"
    contact_zipcode = "12345-1234"
    contact_phone = "4444444444"

    emergency_date_of_birth = FuzzyDate(date(1945, 12, 31))
    emergency_contact = "Emergency Contact Test Person"
    emergency_phone = "1231231234"
    emergency_relationship = "Test Spouse"
    emergency_hospital = "Test Hospital"
    emergency_allergies = "nothing to note here thanks"

    class Meta:
        model = 'registration.RegistrationData'

    @factory.post_generation
    def set_first_last_name(self, created, expected, **kwargs):
        if self.user.first_name and self.user.last_name:
            self.contact_first_name = self.user.first_name
            self.contact_last_name = self.user.last_name
        else:
            self.contact_first_name, self.contact_last_name = get_random_first_last_name(
            )
Пример #8
0
class VehicleFactory(factory.DjangoModelFactory):
    class Meta:
        model = Vehicle

    name = factory.Sequence(lambda n: 'João {0}'.format(n))
    manufacture_year = FuzzyDate(date(2008, 1, 1))
    manufacturer = factory.SubFactory(ManufacturerFactory)
Пример #9
0
class CaseFactory(DjangoModelFactory):
    tenant = SubFactory(TenantFactory)
    status = SubFactory(CaseStatusFactory, tenant=SelfAttribute('..tenant'))
    priority = FuzzyChoice(dict(Case.PRIORITY_CHOICES).keys())
    subject = LazyAttribute(lambda o: faker.word())
    account = SubFactory(AccountFactory, tenant=SelfAttribute('..tenant'))
    expires = FuzzyDate(datetime.date(2015, 1, 1), datetime.date(2016, 1, 1))
    assigned_to = SubFactory(LilyUserFactory, tenant=SelfAttribute('..tenant'))
    type = SubFactory(CaseTypeFactory, tenant=SelfAttribute('..tenant'))
    created_by = SelfAttribute('.assigned_to')

    @factory.post_generation
    def teams(self, create, extracted, **kwargs):
        if not create:
            # Simple build, do nothing.
            return

        if extracted:
            if isinstance(extracted, Team):
                # A single team was passed in, use that.
                self.assigned_to_teams.add(extracted)
            else:
                # A list of teams were passed in, use them.
                for team in extracted:
                    self.assigned_to_teams.add(team)

    class Meta:
        model = Case
Пример #10
0
class DealFactory(DjangoModelFactory):
    tenant = SubFactory(TenantFactory)
    account = SubFactory(AccountFactory, tenant=SelfAttribute('..tenant'))
    contact = SubFactory(ContactFactory, tenant=SelfAttribute('..tenant'))
    amount_once = FuzzyDecimal(42.7)
    amount_recurring = FuzzyDecimal(42.7)
    assigned_to = SubFactory(LilyUserFactory, tenant=SelfAttribute('..tenant'))
    card_sent = FuzzyChoice([True, False])
    contacted_by = SubFactory(DealContactedByFactory,
                              tenant=SelfAttribute('..tenant'))
    currency = FuzzyChoice(dict(CURRENCIES).keys())
    found_through = SubFactory(DealFoundThroughFactory,
                               tenant=SelfAttribute('..tenant'))
    is_checked = FuzzyChoice([True, False])
    name = LazyAttribute(lambda o: faker.word())
    new_business = FuzzyChoice([True, False])
    next_step = SubFactory(DealNextStepFactory,
                           tenant=SelfAttribute('..tenant'))
    next_step_date = FuzzyDate(past_date, future_date)
    status = SubFactory(DealStatusFactory, tenant=SelfAttribute('..tenant'))
    twitter_checked = FuzzyChoice([True, False])
    why_customer = SubFactory(DealWhyCustomerFactory,
                              tenant=SelfAttribute('..tenant'))
    why_lost = SubFactory(DealWhyLostFactory, tenant=SelfAttribute('..tenant'))
    closed_date = LazyAttribute(
        lambda o: faker.date_time_between_dates(past_date, current_date, utc)
        if o.status.is_won or o.status.is_lost else None)

    class Meta:
        model = Deal
Пример #11
0
class EmploymentFactory(DjangoModelFactory):
    """
    A factory for work history
    """
    profile = SubFactory(ProfileFactory)
    city = Faker('city')
    country = Faker('country')
    state_or_territory = Faker('state')
    company_name = Faker('company')
    industry = FuzzyText(suffix=" IT")
    position = Faker('job')
    end_date = FuzzyDate(date(1850, 1, 1))
    start_date = FuzzyDate(date(1850, 1, 1))

    class Meta:
        model = Employment
class EntryGroup(factory.DjangoModelFactory):
    class Meta:
        model = contracts.EntryGroup

    user = factory.SubFactory('timepiece.tests.factories.User')
    project = factory.SubFactory('timepiece.tests.factories.Project')
    end = FuzzyDate(datetime.date.today() - relativedelta(months=1))
Пример #13
0
class EmploymentFactory(DjangoModelFactory):
    """
    A factory for work history
    """
    profile = SubFactory(ProfileFactory)
    city = FuzzyText(suffix=" city")
    country = FuzzyText(suffix=" land")
    state_or_territory = FuzzyText(suffix=" state")
    company_name = FuzzyText(suffix=" XYZ-ABC")
    industry = FuzzyText(suffix=" IT")
    position = FuzzyText(suffix=" developer")
    end_date = FuzzyDate(date(1850, 1, 1))
    start_date = FuzzyDate(date(1850, 1, 1))

    class Meta:  # pylint: disable=missing-docstring
        model = Employment
Пример #14
0
class FinancialAidFactory(DjangoModelFactory):
    """
    Factory for FinancialAid
    """
    # user = SubFactory(UserFactory) is implied, since it is created in the cls.create() method
    tier_program = SubFactory(TierProgramFactory)
    status = FuzzyChoice(
        # the reset status is a special case, so removing it from the options
        [
            status for status in FinancialAidStatus.ALL_STATUSES
            if status != FinancialAidStatus.RESET
        ])
    income_usd = FuzzyFloat(low=0, high=12345)
    original_income = FuzzyFloat(low=0, high=12345)
    original_currency = Faker('currency_code')
    country_of_income = Faker('country_code')
    country_of_residence = Faker('country_code')
    date_exchange_rate = FuzzyDateTime(
        datetime.datetime(2000, 1, 1, tzinfo=UTC))
    date_documents_sent = FuzzyDate(datetime.date(2000, 1, 1))

    @classmethod
    def create(cls, **kwargs):
        """
        Overrides the default .create() method so that if no user is specified in kwargs, this factory
        will create a user with an associated profile without relying on signals.
        """
        if "user" not in kwargs:
            with mute_signals(post_save):
                profile = ProfileFactory.create()
            kwargs["user"] = profile.user
        return super().create(**kwargs)

    class Meta:
        model = FinancialAid
Пример #15
0
class BookingFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = Booking

    date = FuzzyDate(datetime.date(2000, 1, 1))
    singleroomaval = FuzzyInteger(0, 5)
    doubleroomaval = FuzzyInteger(0, 5)
Пример #16
0
class FilingFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = Filing

    datafile = factory.django.FileField(from_path=None)
    date_filed = FuzzyDate(datetime.date(2015, 1, 1))
    filing_list = factory.SubFactory(FilingListFactory)
    cik = factory.SubFactory(CikFactory)
class AuthorFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = Author
    
    firstname = factory.Faker('first_name')
    lastname = factory.Faker('last_name')
    dob = FuzzyDate(datetime.date(2000, 1, 1))
    fullname = factory.LazyAttribute(lambda p: '{} {}'.format(p.firstname, p.lastname))
Пример #18
0
class DemoModel1Factory(factory.DjangoModelFactory):
    char = FuzzyText(length=10, prefix='dm1_')
    integer = FuzzyInteger(1000)
    date = FuzzyDate(datetime.date(2008, 1, 1))
    choice = FuzzyChoice(CHOICES_IDS)

    class Meta:
        model = DemoModel1
Пример #19
0
class FilingListFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = FilingList

    quarter = FuzzyDate(datetime.date(2015, 1, 1))
    datafile = factory.django.FileField(from_path=None)
    filing_quarter = factory.fuzzy.FuzzyInteger(1, 4)
    filing_year = factory.fuzzy.FuzzyInteger(1993, 2020)
Пример #20
0
class BookFactory(DjangoModelFactory):
    class Meta:
        model = Book

    isbn = FuzzyChoice(("978-4-7981-6364-1", "978-4-7981-6364-2"))
    title = FuzzyChoice(("タイトル1", "タイトル2"))
    price = FuzzyInteger(0, 10000)
    publisher = FuzzyChoice(Publisher)
    published = FuzzyDate(datetime.date(2008, 1, 1))
Пример #21
0
class LearningPhdFactory(factory.Factory):
    des1_titulacion = factory.Sequence(lambda n: 'PHD recibido #{0}'.format(n))
    des1_organismo = FuzzyAttribute(
        lambda: 'Universidad #' + str(randint(0, 100)))
    f_expedicion = FuzzyAttribute(
        lambda: random.choice([None, FuzzyDate(d).fuzz()]))

    class Meta:
        model = dict
Пример #22
0
class DataFactory(DjangoModelFactory):
    class Meta:
        model = Data

    date = FuzzyDate(datetime.date(2018, 1, 1))
    campaign = SubFactory(CampaignFactory)
    source = SubFactory(SourceFactory)
    clicks = FuzzyInteger(0, 42)
    impressions = FuzzyInteger(0, 42)
Пример #23
0
class AuthorFactory(DjangoModelFactory):
    first_name = factory.Faker("first_name")
    last_name = factory.Faker("last_name")
    date_of_birth = FuzzyDate(date(1950, 1, 1),
                              NOW.date() - timedelta(days=365))
    date_of_death = factory.LazyAttribute(
        lambda x: x.date_of_birth.replace(year=NOW.year))

    class Meta:
        model = Author
Пример #24
0
class ProfileFactory(factory.Factory):
    class Meta:
        model = Profile

    user = UserFactory()
    course = FuzzyInteger(1, 4).fuzz()
    gpa = FuzzyFloat(0.0, 4.0).fuzz()
    birth_date = FuzzyDate(datetime.date(1996, 1, 1),
                           datetime.date(2003, 1, 1)).fuzz()
    linked_in = factory.Sequence(lambda n: f"google.com/user_{n}")
Пример #25
0
class EventFactory(factory.django.DjangoModelFactory):
    """DjangoModelFactory for object Event."""

    title = factory.Faker('bs')
    description = factory.Faker('sentence')
    date = FuzzyDate(datetime.date(2020, 1, 1))
    user = factory.SubFactory(UserFactory)

    class Meta:
        model = Event
Пример #26
0
class GiftCardCreateRequestFactory(Factory):
    class Meta:
        model = GiftCardCreateRequest

    redeem_code = FuzzyText(length=14,
                            chars=string.ascii_uppercase + string.digits)
    date_of_issue = FuzzyDate(start_date=date.today())
    pin = FuzzyInteger(low=1_000_000_000_000_000, high=9_999_999_999_999_999)
    source = FuzzyChoice(["AMAZON", "WOOHOO", "MAGICPIN", "HDFC SMARTBUY"])
    denomination = FuzzyInteger(low=1000, high=10000, step=1000)
Пример #27
0
class MilestoneFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = 'projects.Milestone'

    status = Milestone.STATUS_IN_PROGRESS
    paid_status = Milestone.PAID_STATUS_DUE
    name = factory.Sequence(lambda n: 'My milestone %d' % n)
    description = factory.Sequence(lambda n: 'My description %d' % n)
    due_date = FuzzyDate(timezone.now().date())
    project = factory.SubFactory('projects.tests.factories.ProjectFactory')
Пример #28
0
class LearningFactory(factory.Factory):
    des1_titulacion = factory.Sequence(lambda n: u'Título #{0}'.format(n))
    des1_grado_titulacion = FuzzyAttribute(lambda: random.choice(
        st_cvn.OFFICIAL_TITLE_TYPE.keys() + ['GRADO', 'FP']))
    des1_organismo = FuzzyAttribute(
        lambda: random.choice([None, 'Universidad #' + str(randint(0, 100))]))
    f_expedicion = FuzzyAttribute(
        lambda: random.choice([None, FuzzyDate(d).fuzz()]))

    class Meta:
        model = dict
Пример #29
0
class TaskFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = 'projects.Task'

    milestone = factory.SubFactory('projects.tests.factories.MilestoneFactory')
    status = FuzzyChoice(Task.STATUS_CHOICES)
    name = factory.Sequence(lambda n: 'Test name %d' % n)
    description = factory.Sequence(lambda n: 'Test description %d' % n)
    due_date = FuzzyDate(timezone.now().date())
    assigned = factory.SubFactory('accounts.tests.factories.UserFactory')
    amount = FuzzyDecimal(100)
Пример #30
0
class BookFactory(factory.DjangoModelFactory):

    title = factory.Faker('sentence', nb_words=4)
    publisher = factory.SubFactory(PublisherFactory)
    publication_date = FuzzyDate(datetime.date(2020, 1, 1))
    price = FuzzyDecimal(10, 100, 2)
    isbn = factory.Faker('isbn13')
    state = FuzzyChoice(dict(BOOK_PUBLISHING_STATUS_CHOICES).keys())

    class Meta:
        model = Book