Пример #1
0
    def test_sanity(self):
        class A(object): pass
        class B(object):
            def __init__(self,x,y):
                self.x = x
                self.y = y
        class B2(object):
            """B2 is a replacement for B, but accepts a third parameter z.
               clients that use the factory will expect a class that has only x and y
            """
            def __init__(self,x,y,z):
                self.x = x
                self.y = y
                self.z = z
        
        f = Factory()
        f.register('A',A)
        f.register('B',B)
        a = f.create('A')

        self.assertEqual(type(a),A)
        b = f.create('B',1,y=3)
        self.assertEqual(type(b),B)
        self.assertEqual(b.x,1)
        self.assertEqual(b.y,3)
        
        def create_B2(x,y): return B2(x,y,z='zzz')
        f.register('B',create_B2)
        b = f.create('B',1,y=3)
        self.assertEqual(b.x,1)
        self.assertEqual(b.y,3)
        self.assertEqual(b.z,'zzz')
    def test_details_modal__delete_all_scheduled_rides(
        self,
        recurring_ride_factory: Factory,
        service_with_recurring_rides: fixture,
    ) -> None:
        """Cancel a booked recurring ride, then delete all remaining rides from the details modal.

        :param recurring_ride_factory: A factory for building recurring rides via the API or UI.
        :param service_with_recurring_rides: A recurring rides service yielded by the API.
        """
        ride: dict = recurring_ride_factory.create(
            service=service_with_recurring_rides)
        self.API.cancel_booked_ride(ride)

        self.rides.visit()

        self.rides.sidebar.select_tab('Active')
        row: SubscriptionRow = self.rides.ride_subscription_table.surface_subscription_row(
            ride['ride_subscription_id'], )
        row.open_kebab_menu()
        row.kebab_menu.details_button.click()

        row.details_modal.delete_all_rides()

        assert row.details_modal.summary == '6 total trips: 1 canceled; 5 deleted'
    def test_details_modal__cancel_ride(
        self,
        recurring_ride_factory: Factory,
        service_with_recurring_rides: fixture,
    ) -> None:
        """Book a recurring ride, then cancel a booked ride from its details modal.

        :param recurring_ride_factory: A factory for building recurring rides via the API or UI.
        :param service_with_recurring_rides: A recurring rides service yielded by the API.
        """
        ride: dict = recurring_ride_factory.create(
            service=service_with_recurring_rides)

        self.rides.visit()

        self.rides.sidebar.select_tab('Active')
        row: SubscriptionRow = self.rides.ride_subscription_table.surface_subscription_row(
            ride['ride_subscription_id'], )
        row.open_kebab_menu()
        row.kebab_menu.details_button.click()

        booked_ride: ScheduledRideRow = row.details_modal.scheduled_rides_list.scheduled_rides[
            0]
        booked_ride.cancel_ride(fake.text())

        assert row.details_modal.summary == '6 total trips: 1 canceled; 5 scheduled'
    def test_details_modal__cancel_all_rides(
        self,
        recurring_ride_factory: Factory,
        service_with_recurring_rides: fixture,
    ) -> None:
        """Book a recurring ride, then cancel all associated rides from its details modal.

        This test is part of the smoke testing battery. Test failure should result in immediate
        remediation efforts as it is a main feature for the application.

        :param recurring_ride_factory: A factory for building recurring rides via the API or UI.
        :param service_with_recurring_rides: A recurring rides service yielded by the API.
        """
        ride: dict = recurring_ride_factory.create(
            service=service_with_recurring_rides)

        self.rides.visit()

        self.rides.sidebar.select_tab('Active')
        row: SubscriptionRow = self.rides.ride_subscription_table.surface_subscription_row(
            ride['ride_subscription_id'], )
        row.open_kebab_menu()
        row.kebab_menu.details_button.click()

        row.details_modal.cancel_all_rides(fake.text())

        assert row.details_modal.summary == '6 total trips: 1 canceled; 5 deleted'
    def test_details_modal__booked_rides_feature_details_link(
        self,
        recurring_ride_factory: Factory,
        service_with_recurring_rides: fixture,
    ) -> None:
        """Check that booked recurring rides feature a details page link.

        :param recurring_ride_factory: A factory for building recurring rides via the API or UI.
        :param service_with_recurring_rides: A recurring rides service yielded by the API.
        """
        ride: dict = recurring_ride_factory.create(
            service=service_with_recurring_rides)

        self.rides.visit()

        self.rides.sidebar.select_tab('Active')
        row: SubscriptionRow = self.rides.ride_subscription_table.surface_subscription_row(
            ride['ride_subscription_id'], )
        row.open_kebab_menu()
        row.kebab_menu.details_button.click()

        booked_ride: ScheduledRideRow = row.details_modal.scheduled_rides_list.scheduled_rides[
            0]

        assert booked_ride.status == 'BOOKED' and booked_ride.details_link.visible
Пример #6
0
    def test_update_recurring_rides__delete_all(
        self,
        recurring_ride_factory: Factory,
        service_with_recurring_rides: fixture,
    ) -> None:
        """As a Dispatcher, check to ensure that recurring rides may be deleted.

        :param recurring_ride_factory: A factory for building recurring rides via the API or UI.
        :param service_with_recurring_rides: A recurring rides service yielded by the API.
        """
        ride: dict = recurring_ride_factory.create(
            service=service_with_recurring_rides)
        self.API.cancel_booked_ride(ride)

        self.rides.visit()

        self.rides.sidebar.select_tab('Active')
        row: SubscriptionRow = self.rides.ride_subscription_table.surface_subscription_row(
            ride['ride_subscription_id'], )
        row.open_kebab_menu()
        row.kebab_menu.cancel_all_button.click()

        row.deletion_modal.confirm_button.click()

        assert row.total_cancels == '1 of 6'
Пример #7
0
    def test_recurring_rides__access(
        self,
        recurring_ride_factory: Factory,
        service_with_recurring_rides: fixture,
    ) -> None:
        """As an Admin, check to ensure that recurring rides are available for view.

        :param recurring_ride_factory: A factory for building recurring rides via the API or UI.
        :param service_with_recurring_rides: A recurring rides service yielded by the API.
        """
        recurring_ride_factory.create(service=service_with_recurring_rides)

        self.rides.visit()

        self.rides.sidebar.container.is_text_visible('Recurring Rides')
        assert 'Recurring Rides' in self.rides.sidebar.container.html
Пример #8
0
 def run(self):
     modules = self._module_conf.get_modules()
     factory = Factory()
     for module in modules:
         test_base = factory.create(module)
         test_base.initialize(self._module_conf.get_config(module))
         test_base.run()
Пример #9
0
    def test_registration__failure__min_max_length_inputs(
        self,
        user_factory: Factory,
        username: fixture,
        phone: fixture,
        password: fixture,
        repeat_password: fixture,
    ) -> None:
        """Input account data with min and max length inputs, then check for a failure state.

        :param user_factory: A factory for generating user data.
        """
        user: User = user_factory.create(
            username=username,
            phone=phone,
            password=password,
            repeat_password=repeat_password,
        )

        self.registration.visit()
        self.registration.wait_for_page_to_load()
        self.registration.fill_registration_form(user)
        self.registration.submit_button.click()

        assert (
            MESSAGES.AUTH.USERNAME_MIN_LENGTH and
            f'{MESSAGES.AUTH.PHONE_VALIDATION}\n{MESSAGES.AUTH.PHONE_MIN_LENGTH}'
            and MESSAGES.AUTH.PASSWORD_MIN_LENGTH
            in self.registration.inline_error_messages)
    def test_multiple_rides_cannot_be_prioritized(
        self, ride_factory: Factory, service: fixture,
    ) -> None:
        """Prioritize a ride, attempt to prioritize another, then check for a failure state.

        :param ride_factory: A factory for building rides via the API or UI.
        :param service: A service yielded by the API.
        """
        ride_one: dict = ride_factory.create(service=service)
        ride_two: dict = ride_factory.create(service=service)

        self.dispatch.visit()

        card_one: RideCard = self.dispatch.ride_card_panel.surface_ride_card(ride_one)
        card_one.open_kebab_menu()

        try:
            card_one.kebab_menu.open_ride_prioritization_modal()
        except AttributeError:
            pytest.xfail('Prioritization cannot be tested. Another ride is currently prioritized.')

        card_one.prioritization_modal.prioritize_ride('pick up')

        card_two: RideCard = self.dispatch.ride_card_panel.surface_ride_card(ride_two)
        card_two.open_kebab_menu()

        assert card_two.kebab_menu.prioritize_disabled() is not False
    def test_details_modal__delete_ride(
        self,
        recurring_ride_factory: Factory,
        service_with_recurring_rides: fixture,
    ) -> None:
        """Book a recurring ride, then delete a scheduled ride from its details modal.

        :param recurring_ride_factory: A factory for building recurring rides via the API or UI.
        :param service_with_recurring_rides: A recurring rides service yielded by the API.
        """
        ride: dict = recurring_ride_factory.create(
            service=service_with_recurring_rides)

        self.rides.visit()

        self.rides.sidebar.select_tab('Active')
        row: SubscriptionRow = self.rides.ride_subscription_table.surface_subscription_row(
            ride['ride_subscription_id'], )
        row.open_kebab_menu()
        row.kebab_menu.details_button.click()

        scheduled_ride: ScheduledRideRow = row.details_modal.scheduled_rides_list.scheduled_rides[
            1]
        scheduled_ride.delete_ride()

        assert scheduled_ride.status == 'DELETED'
Пример #12
0
def service_with_fare(service_factory: Factory) -> Generator[dict, None, None]:
    """Instantiate and tear down a fare service.

    :param service_factory: A factory for building services via the API.
    """
    fare_service: dict = service_factory.create(fare_service=True)

    yield fare_service

    _service_api.delete_service(fare_service)
Пример #13
0
def service(service_factory: Factory) -> Generator[dict, None, None]:
    """Instantiate and tear down a service for testing OnDemand applications.

    :param service_factory: A factory for building services via the API.
    """
    service: dict = service_factory.create()

    yield service

    _service_api.delete_service(service)
Пример #14
0
def group(group_factory: Factory) -> Generator[dict, None, None]:
    """Instantiate and tear down a group for testing OnDemand applications.

    :param group_factory: A factory for building a group via the API.
    """
    group: dict = group_factory.create()

    yield group

    _groups_api.delete_group(group)
Пример #15
0
def region(region_factory: Factory) -> Generator[dict, None, None]:
    """Instantiate and tear down a region for testing OnDemand applications.

    :param region_factory: A factory for building regions via the API.
    """
    region: dict = region_factory.create()

    yield region

    _regions_api.delete_region(region)
Пример #16
0
def rider_address(address_factory: Factory) -> Generator[dict, None, None]:
    """Instantiate and tear down an address for testing the OnDemand Web application.

    :param address_factory: A factory for building addresses via the API.
    """
    rider_address: dict = address_factory.create(rider_address=True)

    yield rider_address

    _addresses_api.delete_address(rider_address, rider_address=True)
Пример #17
0
def vehicle(vehicle_factory: Factory) -> Generator[dict, None, None]:
    """Instantiate and tear down a vehicle for testing OnDemand applications.

    :param vehicle_factory: A factory for building vehicles via the API or UI.
    """
    vehicle: dict = vehicle_factory.create()

    yield vehicle

    _vehicles_api.delete_vehicle(vehicle)
Пример #18
0
def service_with_managed_mode(
        service_factory: Factory) -> Generator[dict, None, None]:
    """Instantiate and tear down a service with managed mode enabled.

    :param service_factory: A factory for building services via the API.
    """
    managed_mode_service: dict = service_factory.create(managed_mode=True)

    yield managed_mode_service

    _service_api.delete_service(managed_mode_service)
Пример #19
0
def wheelchair_vehicle(
        vehicle_factory: Factory) -> Generator[dict, None, None]:
    """Instantiate and tear down a wheelchair enabled vehicle for testing OnDemand applications.

    :param vehicle_factory: A factory for building vehicles via the API or UI.
    """
    wheelchair_vehicle: dict = vehicle_factory.create(wheelchair_vehicle=True)

    yield wheelchair_vehicle

    _vehicles_api.delete_vehicle(wheelchair_vehicle)
Пример #20
0
def service_with_hub_address(
        service_factory: Factory) -> Generator[dict, None, None]:
    """Instantiate and tear down a service with a hub address.

    :param service_factory: A factory for building services via the API.
    """
    hub_service: dict = service_factory.create(hub_address=True)

    yield hub_service

    _service_api.delete_service(hub_service)
Пример #21
0
    def test_booked_rides__no_access(self, ride_factory: Factory, service: fixture) -> None:
        """As an Agent, ensure that I may not view the Details page for a ride I have not booked.

        :param ride_factory: A factory for building rides via the API or UI.
        :param service: A service yielded by the API.
        """
        ride: dict = ride_factory.create(service=service)

        self.rides.navigate_to_details_by_ride_id(ride)

        assert bool(self.details.loaded) is False
Пример #22
0
def service_with_remove_exception(
        service_factory: Factory) -> Generator[dict, None, None]:
    """Instantiate and tear down a remove exception service for testing OnDemand applications.

    :param service_factory: A factory for building services via the API.
    """
    remove_exception_service: dict = service_factory.create(
        exception_service_removed=True)

    yield remove_exception_service

    _service_api.delete_service(remove_exception_service)
Пример #23
0
def service_with_recurring_rides(
        service_factory: Factory) -> Generator[dict, None, None]:
    """Instantiate and tear down a service with recurring rides enabled.

    :param service_factory: A factory for building services via the API.
    """
    recurring_ride_service: dict = service_factory.create(
        recurring_ride_service=True)

    yield recurring_ride_service

    _service_api.delete_service(recurring_ride_service)
Пример #24
0
def service_with_add_exception(
        service_factory: Factory) -> Generator[dict, None, None]:
    """Instantiate and tear down an add exception service.

    :param service_factory: A factory for building services via the API.
    """
    add_exception_service: dict = service_factory.create(
        exception_service_added=True)

    yield add_exception_service

    _service_api.delete_service(add_exception_service)
Пример #25
0
    def test_update_rides__cancel(self, ride_factory: Factory,
                                  service: fixture) -> None:
        """As a Dispatcher, check to ensure that rides may be cancelled."""
        cancellation_reason: str = fake.sentence(nb_words=3)
        ride: dict = ride_factory.create(service=service)

        self.rides.visit()

        self.rides.cancel_ride(cancellation_reason, ride)

        row: RideRow = self.rides.single_rides_table.surface_ride_row(ride)
        assert row.ride_status == 'Canceled'
Пример #26
0
def service_with_in_advance(
        service_factory: Factory) -> Generator[dict, None, None]:
    """Instantiate and tear down a service with advanced rides enabled.

    :param service_factory: A factory for building services via the API.
    """
    future_ride_service: dict = service_factory.create(
        future_ride_service=True)

    yield future_ride_service

    _service_api.delete_service(future_ride_service)
Пример #27
0
    def test_filter_by_rider_name(self, ride_factory: Factory,
                                  service: fixture) -> None:
        """Input a rider name to the filter field, then check for a success state."""
        ride: dict = ride_factory.create(service=service)
        rider_info: dict = ride['rider']
        rider_name: str = f'{rider_info["first_name"]} {rider_info["last_name"]}'

        self.rides.visit()
        self.rides.filters.filter_by_ride_info(rider_name)
        rows: List[RideRow] = self.rides.single_rides_table.ride_rows

        assert len(rows) == 1
Пример #28
0
    def test_filter_by_service(self, ride_factory: Factory,
                               service_factory: Factory) -> None:
        """Check a service within the service filter field, then check for a success state.

        This test constructs two separate services and rides in order to ensure that the core
        functionality can be tested in earnest. Both services are manually torn down at the
        end of this test.
        """
        service_one: dict = service_factory.create()
        service_two: dict = service_factory.create()
        ride: dict = ride_factory.create(service=service_one)
        ride_factory.create(service=service_two)

        self.rides.visit()

        self.rides.filters.filter_service_by_id(service_one['service_id'])
        row: RideRow = self.rides.single_rides_table.surface_ride_row(ride)

        assert row is None

        self.services_API.delete_service(service_one)
        self.services_API.delete_service(service_two)
Пример #29
0
    def test_registration__failure__passwords_must_match(
            self, user_factory: Factory) -> None:
        """Input account data with a mismatched password, then check for a failure state.

        :param user_factory: A factory for generating user data.
        """
        user: User = user_factory.create(password=fake.password())

        self.registration.visit()
        self.registration.wait_for_page_to_load()
        self.registration.fill_registration_form(user)
        self.registration.submit_button.click()

        assert MESSAGES.AUTH.PASSWORD_MISMATCH in self.registration.inline_error_messages
Пример #30
0
    def test_ride_data_prevents_archive(self, ride_factory: Factory, service: fixture) -> None:
        """Attempt to archive a service with ride data, then check for a failure state.

        :param ride_factory: RideFactory for creating ride objects.
        :param service: A service built with the service API.
        """
        _: dict = ride_factory.create(service=service)

        self.services.visit()
        card = self.services.service_card_list.surface_service_card(service)

        card.open_archive_modal()

        assert self.services.service_card_list.card_archived(service) is False
Пример #31
0
    def test_registration__failure__username_in_use(
            self, user_factory: Factory) -> None:
        """Input account data for an existing user, then check for a failure state.

        :param user_factory: A factory for generating user data.
        """
        user: User = user_factory.create(username=USERS.USERNAME)

        self.registration.visit()
        self.registration.wait_for_page_to_load()
        self.registration.fill_registration_form(user)
        self.registration.submit_button.click()

        assert self.registration.user_exists_error.visible
Пример #32
0
 def test_create(self):
     faker = Factory.create()
     result = faker.marriage_status()
     result = faker.male_nation()
     pass