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
def test_travel_ticket_price_set_wrong_type(default_travel: Travel): """ Test case for incorrect Travel.ticket_price method use TEST CASE: Calling ticked_price method to set non float flight price. EXPECTED BEHAVIOUR: The method raise a TypeError exception because the price is non float. """ with pytest.raises(TypeError): default_travel.ticket_price = 5
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
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
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