class Params:
     unpublished = Trait(publish_after=Faker(
         'future_datetime', end_date='+30d', tzinfo=timezone.utc))
     has_expiry = Trait(expires=Faker(
         'future_datetime', end_date='+30d', tzinfo=timezone.utc))
     expired = Trait(expires=Faker(
         'past_datetime', start_date='-30d', tzinfo=timezone.utc))
Exemple #2
0
    class Params:
        paid = True

        free = Trait(
            box_count=1,
            bandwidth=100,
            forwards=2,
            reserved_config=0,
            cost=0,
            name="free",
            stripe_id=None,
        )

        waiting = Trait(
            box_count=0,
            bandwidth=0,
            forwards=0,
            reserved_config=0,
            cost=0,
            name="waiting",
            stripe_id=None,
        )

        beta = Trait(
            box_count=2,
            bandwidth=1000,
            forwards=10,
            reserved_config=1,
            cost=0,
            name="beta",
            stripe_id=None,
        )
 class Params:
     active = True
     old_levels = Trait(
         _using_results_framework=ProgramM.NOT_MIGRATED
     )
     has_rf = Trait(
         generate_levels=PostGeneration(generate_mc_levels)
     )
Exemple #4
0
 class Params:
     group = Trait(profile=SubFactory(BasicUserProfileFactory, group=True),
                   name=Faker('color_name'))
     active = Trait(
         profile=SubFactory(BasicUserProfileFactory, is_active=True))
     extended_profile = Trait(
         profile=SubFactory(ExtendedUserProfileFactory))
     use_custom_name = Trait(
         profile=SubFactory(BasicUserProfileFactory, use_custom_name=True))
Exemple #5
0
 class Params:
     unexpired = Trait(
         enrollment=now_in_utc() + timedelta(days=1),
         certificate=now_in_utc() + timedelta(days=1),
         current_grade=now_in_utc() + timedelta(days=1),
     )
     expired = Trait(
         enrollment=now_in_utc() - timedelta(days=1),
         certificate=now_in_utc() - timedelta(days=1),
         current_grade=now_in_utc() - timedelta(days=1),
     )
 class Params:  # pylint: disable=missing-docstring
     percent = Trait(
         amount_type='percent-discount',
         amount=FuzzyDecimal(0, 1),
     )
     fixed = Trait(
         amount_type='fixed-discount',
         amount=FuzzyDecimal(50, 1000),
     )
     program = Trait(content_object=SubFactory(ProgramFactory))
     course = Trait(content_object=SubFactory(CourseFactory))
     course_run = Trait(content_object=SubFactory(CourseRunFactory))
Exemple #7
0
 class Params:
     unpublished = Trait(
         publish_after=Faker('date_time', tzinfo=timezone.utc
                             ) if RANDOM_SEED and not TESTING else
         Faker('future_datetime', end_date='+30d', tzinfo=timezone.utc))
     has_expiry = Trait(
         expires=Faker('date_time', tzinfo=timezone.utc
                       ) if RANDOM_SEED and not TESTING else
         Faker('future_datetime', end_date='+30d', tzinfo=timezone.utc))
     expired = Trait(
         expires=Faker('date_time', tzinfo=timezone.utc
                       ) if RANDOM_SEED and not TESTING else
         Faker('past_datetime', start_date='-30d', tzinfo=timezone.utc))
     video = Trait(is_video=True)
Exemple #8
0
 class Params:
     # Adds a patched PatchPort with a subnet
     patched_with_subnet = Trait(
         patch_ports=RelatedFactoryList('tests.factories.facilities.PatchPortFactory', 'room',
                                        size=1,
                                        patched=True,
                                        switch_port__default_vlans__create_subnet=True)
     )
Exemple #9
0
    class Params:
        """Optional params which change factory output when True.

        :param rider_address: Generate an address for the OnDemand Web application.

        :example usage: AddressFactory.create(rider_address=True)
        """

        rider_address = Trait(url=API.build_api_url('/me/rider/addresses'))
 class Params:
     validated = Trait(
         filled_out=True,
         phone_number='+1-800-888-8888',
         country='US',
         state_or_territory='US-MA',
         postal_code='02142',
         agreed_to_terms_of_service=True,
     )
    class Params:
        """Optional params which change factory output when True.

        :param future_recurring_ride: Create a recurring ride for a future date.
        :param ride_with_note: Create a recurring ride with a driver note.
        :param same_day_future_recurring_ride: Create a same-day recurring ride for a future time.

        :example usage: RecurringRideFactory.create(future_recurring_ride=True)
        """

        future_recurring_ride: bool = Trait(ride=RideFactory.build(
            future_ride=True))

        ride_with_note: bool = Trait(ride=LazyAttribute(
            lambda _: RideFactory.build(ride_with_note=True)), )

        same_day_future_recurring_ride: bool = Trait(
            ride=RideFactory.build(same_day_future_ride=True), )
Exemple #12
0
    class Params:
        """Optional boolean params which change factory output when True.

        :param exception_service_added: Create a service with an add service exception.
        :param exception_service_removed: Create a service with a remove service exception.
        :param expired_service: Create a service that has expired.
        :param fare_service: Create a service with a fare payment.
        :param future_ride_service: Create a service with future rides enabled.
        :param hub_address: Create a service with a hub.
        :param recurring_ride_service: Create a service with recurring rides enabled.

        :example usage: ServiceFactory.create(expired_service=True)
        """

        exception_service_added: bool = Trait(exceptions=[
            {
                'end_time':
                f'{date.today() + timedelta(days=22)}T18:00:00.000Z',
                'message': 'Testing Service Addition.',
                'start_time':
                f'{date.today() + timedelta(days=15)}T09:30:00.000Z',
                'type': 'service_added',
            },
        ], )

        exception_service_removed: bool = Trait(exceptions=[
            {
                'end_time':
                f'{date.today() + timedelta(days=7)}T18:00:00.000Z',
                'message': 'Testing Service Removal.',
                'start_time':
                f'{date.today() + timedelta(days=3)}T09:30:00.000Z',
                'type': 'service_removed',
            },
        ], )

        expired_service: bool = Trait(
            end_date=date.isoformat(date.today() - timedelta(days=5)),
            start_date=date.isoformat(date.today() - timedelta(days=10)),
        )

        fare_service: bool = Trait(
            fare_required=True,
            fare_price=2.0,
        )

        future_ride_service: bool = Trait(in_advance_enabled=True)

        hub_address: bool = Trait(addresses=[{
            'hub': True,
            'pickup': True,
            'dropoff': True,
            'address_id': '7539'
        }], )

        recurring_ride_service: bool = Trait(
            in_advance_enabled=True,
            recurring_rides_enabled=True,
        )
Exemple #13
0
    class Params:
        """Optional params which change factory output when True.

        :param wheelchair_vehicle: Generate a vehicle with wheelchair accessibility.

        :example usage: VehicleFactory.create(wheelchair_vehicle=True)
        """

        wheelchair_vehicle: bool = Trait(wheelchair_capacity=2,
                                         wheelchair_impact=2)
Exemple #14
0
    class Params:
        paid = True

        free = Trait(
            tunnel_count=1,
            bandwidth=100,
            forwards=2,
            reserved_subdomains=0,
            cost=0,
            name="free",
            stripe_id=None,
        )

        waiting = Trait(
            tunnel_count=0,
            bandwidth=0,
            forwards=0,
            reserved_subdomains=0,
            cost=0,
            name="waiting",
            stripe_id=None,
        )

        beta = Trait(
            tunnel_count=2,
            bandwidth=1000,
            forwards=10,
            reserved_subdomains=1,
            cost=0,
            name="beta",
            stripe_id=None,
        )

        admin = Trait(
            tunnel_count=20,
            bandwidth=10000,
            forwards=100,
            reserved_subdomains=5,
            cost=0,
            name="admin",
            stripe_id=None,
        )
Exemple #15
0
 class Params:
     verified = False
     unverified = Trait(
         data=LazyAttribute(lambda x: {
             "is_active": True,
             "mode": "audit",
             "user": x.user.username,
             "course_details": {
                 "course_id": x.course_run.edx_course_key,
             }
         })
     )
Exemple #16
0
 class Params:
     lop_indicator = Trait(
         lop_target=1000,
         target_frequency=IndicatorM.LOP,
         periodic_target=RelatedFactory(
             'factories.indicators_models.PeriodicTargetFactory',
             'indicator',
             target=1000,
             start_date=SelfAttribute('indicator.program.reporting_period_start'),
             end_date=SelfAttribute('indicator.program.reporting_period_end'),
         )
     )
    class Params:
        """Optional params which change factory output when True.

        :param account_rider: Generate a rider using an existing account.

        :example usage: RiderFactory.create(account_rider=True)
        """

        account_rider: bool = Trait(
            first_name='QA',
            last_name='Rider',
            email='*****@*****.**',
            username='******',
        )

        superuser_account_rider: bool = Trait(
            first_name='QA',
            last_name='User',
            email='*****@*****.**',
            username='******',
        )
Exemple #18
0
    class Params:
        """Optional params which change factory output when True.

        :param account_ride: Generate a ride using a rider with an existing account.
        :param future_ride: Generate a ride for a future date.
        :param same_day_future_ride: Generate a same day ride for a future time.
        :param hub_ride: Generate a ride which uses a hub address as pick up or drop off.

        :example usage: RideFactory.create(hub_ride=True)
        """

        account_ride: bool = Trait(rider=RiderFactory.build(
            account_rider=True))

        future_ride: bool = Trait(pickup={
            'address':
            '4506 Emperor Boulevard Durham, NC, USA',
            'position': {
                'latitude': 35.8724046,
                'longitude': -78.8426551
            },
            'priority':
            0,
            'timestamp':
            date_objects.build_date_string(days=1),
        }, )

        hub_ride: bool = Trait(pickup={
            'address': 'Stop #300 - TransLoc Office',
            'position': {
                'latitude': 35.8750625,
                'longitude': -78.8406699
            },
            'priority': 0,
        }, )

        ride_with_note: bool = Trait(note=fake.sentence(nb_words=3))

        same_day_future_ride: bool = Trait(pickup={
            'address':
            '4506 Emperor Boulevard Durham, NC, USA',
            'position': {
                'latitude': 35.8724046,
                'longitude': -78.8426551
            },
            'priority':
            0,
            'timestamp':
            date_objects.build_date_string(hours=1),
        }, )

        superuser_account_ride: bool = Trait(rider=RiderFactory.build(
            superuser_account_rider=True))
Exemple #19
0
 class Params:
     active = Trait(is_active=True)
     use_custom_name = Trait(custom_name=Faker('user_name'))
     group = Trait(is_group=True)
Exemple #20
0
 class Params:
     with_traffic_group = Trait(default_traffic_group=SubFactory(
         'tests.factories.traffic.TrafficGroupFactory'))
Exemple #21
0
 class Params:
     with_program_run = Trait(program_run=SubFactory(ProgramRunFactory))
Exemple #22
0
def trait(name, attrs, parent=None):
    if hasattr(local, 'working_factory'):
        _get_active_factory().trait(name, attrs, parent)
    else:
        traits[name] = Trait(attrs, parent)
Exemple #23
0
 class Params:
     no_cta = Trait(cta=None)
Exemple #24
0
 class Params:
     has_expired = Trait(
         expiry_date=past_datetime_faker
     )
Exemple #25
0
 class Params:
     no_profile = Trait(profile=None)
Exemple #26
0
 class Params:
     has_company_affiliation = Trait(company=SubFactory(CompanyFactory))
Exemple #27
0
 class Params:
     mozillauser = Trait(published_by=Iterator(
         EmailUser.objects.filter(email__icontains='mozilla')))
     is_featured = Trait(featured=True)
     is_published_by_creator = Trait(published_by_creator=True)
Exemple #28
0
 class Params:
     staff = Trait(is_staff=True)
     admin = Trait(is_superuser=True)
     extended_profile = Trait(
         profile=SubFactory(ExtendedUserProfileFactory))
Exemple #29
0
 class Params:
     mc_template = Trait(
         name=Sequence(
             lambda n: LevelTierM.get_templates()['mc_standard']['tiers'][n]
         )
     )
Exemple #30
0
 class Params:
     patched = Trait(
         switch_port=SubFactory('tests.factories.host.SwitchPortFactory')
     )