Exemple #1
0
def test_travel_cost_cars(default_travel: Travel, default_cars):
    """ Test case for Travel.cost method with Flights and Cars

    TEST CASE:
        Calling cost method to check the total cost with only an instances of Flights and Cars

    EXPECTED BEHAVIOUR:
        The method returns only the sum of flights cost and cars cost.
    """

    default_travel.ticket_price = MOCKED_TICKET_PRICE
    default_travel.car_price = MOCKED_CAR_PRICE
    default_travel._cars = default_cars

    assert default_travel.cost == DEFAULT_FLIGHT_TOTAL_COST + DEFAULT_CAR_TOTAL_COST
Exemple #2
0
def test_full_travel_ctor(default_flights: Flights, default_hotels: Hotels, default_cars: Cars):
    """ Test case for Travel.__init__(**) method with Flights, Hotels and Cars

    RESTRICTION:
        The Flights, Hotels and Cars instances should have elements in.

    TEST CASE:
        Insertion of a Travel object from Flights, Hotels, Cars instances and number of travelers.

    EXPECTED BEHAVIOUR:
        The object is instantiated with the default values of Flights, Hotels and Cars.
    """

    travel = Travel(DEFAULT_NUM_TRAVELERS, default_flights, default_hotels, default_cars)

    assert isinstance(travel, Travel)

    assert len(travel._flights) != 0
    assert len(travel._hotels) != 0
    assert len(travel._cars) != 0
    assert len(travel._flights) == len(default_flights)
    assert len(travel._hotels) == len(default_hotels)
    assert len(travel._cars) == len(default_cars)

    assert travel.ticket_price == travel._default_price
    assert travel.hotel_price == travel._default_price
    assert travel.car_price == travel._default_price
    assert travel.cost == float()
Exemple #3
0
def test_travel_set_negative_value_to_ticket_property(default_travel: Travel):
    """ Test case for incorrect Travel.ticket_price method use

    TEST CASE:
        Calling ticket_price method to set a negative flight price.

    EXPECTED BEHAVIOUR:
        The method raise a ValueError exception because the price is negative.
    """

    with pytest.raises(ValueError):
        default_travel.ticket_price = -1.0
Exemple #4
0
def test_travel_cost_cannot_be_set(default_travel: Travel):
    """ Test case for invalid Travel.cost set

    TEST CASE:
        Set a value to Travel.cost as if it was a variable

    EXPECTED BEHAVIOUR:
        The method raises an AttributeError exception.
    """

    with pytest.raises(AttributeError):
        default_travel.cost = float()
Exemple #5
0
def test_travel_car_price_set_wrong_type(default_travel: Travel):
    """ Test case for incorrect Travel.car_price method use

    TEST CASE:
        Calling car_price method to set non float car price.

    EXPECTED BEHAVIOUR:
        The method raise a TypeError exception because the price is non float.
    """

    with pytest.raises(TypeError):
        default_travel.car_price = 5
def full_reservation(default_flights, default_user, default_hotels,
                     default_cars, mock_fetch_prices):
    """ Fixture to create a Reservation object from a default values of User, Travel with Flights, Cars and Hotels.

    """

    res = Reservation(
        Travel(DEFAULT_NUM_TRAVELERS, default_flights, default_hotels,
               default_cars))
    res._user = default_user
    res._payment_method = DEFAULT_CARD_TYPE
    res._payment_data = default_payment_data
    return res
Exemple #7
0
def test_travel_set_positive_value_to_room_property(default_travel: Travel):
    """ Test case for Travel.hotel_price and Travel._hotel_price methods

    TEST CASE:
        Calling hotel_price method to set a hotel price and _hotel_price to get that price.

    EXPECTED BEHAVIOUR:
        The methods set and get the prices for a hotel correctly.
    """

    default_travel.hotel_price = 5.0

    assert default_travel._hotel_price != 0.0
    assert default_travel._hotel_price == 5.0
Exemple #8
0
def test_travel_set_positive_value_to_ticket_property(default_travel: Travel):
    """ Test case for Travel.ticket_price and Travel._ticket_price methods

    TEST CASE:
        Calling ticket_price method to set a flight price and _ticked_price to get that price.

    EXPECTED BEHAVIOUR:
        The methods set and get the prices for a flight correctly.
    """

    default_travel.ticket_price = 5.0

    assert default_travel._ticket_price != 0.0
    assert default_travel._ticket_price == 5.0
Exemple #9
0
def test_travel_cost_only_flights(default_travel: Travel):
    """ Test case for Travel.cost method with Flights

    TEST CASE:
        Calling cost method to check the total cost with only an instance of Flights

    EXPECTED BEHAVIOUR:
        The method returns only the cost of the flights.
        Expected cost = num_flights * passengers_per_flight * ticket_price
    """

    default_travel.ticket_price = MOCKED_TICKET_PRICE

    assert default_travel.cost == DEFAULT_FLIGHT_TOTAL_COST
Exemple #10
0
def default_travel(default_flights):
    """ Fixture to create a Travel object from a default values and flights.

    """

    return Travel(DEFAULT_NUM_TRAVELERS, default_flights)