Ejemplo n.º 1
0
    def test_build__override_default_values(self) -> None:
        """Check that RecurringRideFactory values may be overridden post-build."""
        ride: dict = RecurringRideFactory.build()
        default_ride_status: str = ride['ride']['status']
        ride['ride']['status'] = 'In Progress'

        assert ride['ride']['status'] != default_ride_status
Ejemplo n.º 2
0
    def test_build__params__same_day_future_ride(self) -> None:
        """Check that a same day future recurring ride is built from the RecurringRideFactory."""
        same_day_future_ride: dict = RecurringRideFactory.build(same_day_future_recurring_ride=True)

        assert (
            date.isoformat(date.today() + timedelta(hours=3))
            in same_day_future_ride['ride']['pickup']['timestamp']
        )
Ejemplo n.º 3
0
    def test_create__returns_type_dict(self, service: fixture) -> None:
        """Check that a dictionary is created from the RecurringRideFactory.

        :param service: A recurring ride service.
        """
        ride: dict = RecurringRideFactory.create(service=service)

        assert type(ride) == dict
Ejemplo n.º 4
0
    def test_create__params__ride_with_note(self, service: fixture) -> None:
        """Check that a ride with note is created from the RecurringRideFactory.

        :param service: A recurring ride service.
        """
        ride: dict = RecurringRideFactory.create(service=service, ride_with_note=True)

        assert ride['ride']['note'] is not None
Ejemplo n.º 5
0
    def ride(self) -> Generator[dict, None, None]:
        """Instantiate a recurring ride for RecurringRidesAPI method testing."""
        service: dict = ServiceFactory.create(recurring_ride_service=True)
        ride: dict = RecurringRideFactory.create(service=service)

        yield ride

        self.services_api.delete_service(service)
Ejemplo n.º 6
0
    def test_create__params__future_recurring_ride(self, service: fixture) -> None:
        """Check that a future recurring ride is created from the RecurringRideFactory.

        :param service: A recurring ride service.
        """
        ride = RecurringRideFactory.create(service=service, future_recurring_ride=True)
        expected_pickup: str = ride['ride']['pickup']['timestamp']

        assert date.isoformat(date.today() + timedelta(days=1)) in expected_pickup
Ejemplo n.º 7
0
    def test_create_recurring_ride__success(self) -> None:
        """Check that a recurring ride may be created."""
        service: dict = ServiceFactory.create(recurring_ride_service=True)
        ride_data: dict = RecurringRideFactory.build(
            ride=RideFactory.build(service_id=service['service_id']),
        )

        try:
            self.recurring_rides_api.create_recurring_ride(ride_data)
            self.services_api.delete_service(service)
        except HTTPError:
            pytest.fail('Test failed due to HTTPError.', pytrace=True)
Ejemplo n.º 8
0
    def test_build__subsequent_calls_return_new_recurring_ride(self) -> None:
        """Check that a new RecurringRide is returned from the RideFactory build method."""
        ride_one: dict = RecurringRideFactory.build()
        ride_two: dict = RecurringRideFactory.build()

        assert ride_one != ride_two
Ejemplo n.º 9
0
    def test_build__returns_type_recurring_dict(self) -> None:
        """Check that a dictionary type is built from the RecurringRideFactory build method."""
        ride = RecurringRideFactory.build()

        assert type(ride) == dict
Ejemplo n.º 10
0
    def test_build__requires_no_params(self) -> None:
        """Check that the RecurringRideFactory build method does not require params."""
        ride: dict = RecurringRideFactory.build()

        assert ride is not None
Ejemplo n.º 11
0
    def test_build__params__ride_with_note(self) -> None:
        """Check that a ride with note is built from the RecurringRideFactory."""
        ride_with_note: dict = RecurringRideFactory.build(ride_with_note=True)

        assert ride_with_note['ride']['note'] is not None
Ejemplo n.º 12
0
    def test_build__params__future_recurring_ride(self) -> None:
        """Check that a future recurring ride is built from the RecurringRideFactory."""
        future_ride: dict = RecurringRideFactory.build(future_recurring_ride=True)
        expected_pickup: str = future_ride['ride']['pickup']['timestamp']

        assert date.isoformat(date.today() + timedelta(days=1)) in expected_pickup
Ejemplo n.º 13
0
    def test_build__generate_rides_list(self) -> None:
        """Check that the RecurringRideFactory build method generates a rides list."""
        ride: dict = RecurringRideFactory.build()

        assert ride['rides'] is not None
Ejemplo n.º 14
0
 def test_create__requires_service_param(self) -> None:
     """Check that the RecurringRideFactory create method requires a service param."""
     with pytest.raises(TypeError) as e:
         RecurringRideFactory.create()  # type: ignore
     assert "required positional argument: 'service'" in str(e.value)