def test_two_bikes_four_weeks(self): app = Rental('week', 4, 2) self.assertEqual(app.rent_bikes(), 480, 'Wrong price for rental of 2 bikes 4 weeks')
def test_four_bikes_six_weeks(self): app = Rental('week', 6, 4) self.assertEqual(app.rent_bikes(), 1008, 'Wrong price for rental of 4 bikes 6 weeks')
def test_one_bike_one_hour(self): app = Rental('hour', 1, 1) self.assertEqual(app.rent_bikes(), 5, 'Wrong price for rental of 1 bike 1 hour')
def test_one_bike_three_weeks(self): app = Rental('week', 3, 1) self.assertEqual(app.rent_bikes(), 180, 'Wrong price for rental of 1 bike 3 weeks')
def test_four_bikes_six_days(self): app = Rental('day', 6, 4) self.assertEqual(app.rent_bikes(), 336, 'Wrong price for rental of 4 bikes 6 days')
def test_one_bike_one_week(self): app = Rental('week', 1, 1) self.assertEqual(app.rent_bikes(), 60, 'Wrong price for rental of 1 bike 1 week')
def test_one_bike_three_days(self): app = Rental('day', 3, 1) self.assertEqual(app.rent_bikes(), 60, 'Wrong price for rental of 1 bike 3 days')
def test_two_bikes_four_days(self): app = Rental('day', 4, 2) self.assertEqual(app.rent_bikes(), 160, 'Wrong price for rental of 2 bikes 4 days')
def test_one_bike_one_day(self): app = Rental('day', 1, 1) self.assertEqual(app.rent_bikes(), 20, 'Wrong price for rental of 1 bike 1 day')
def test_four_bikes_seven_hour(self): app = Rental('hour', 7, 4) self.assertEqual(app.rent_bikes(), 98, 'Wrong price for rental of 4 bikes 7 hours')
def test_two_bikes_two_hours(self): app = Rental('hour', 2, 2) self.assertEqual(app.rent_bikes(), 20, 'Wrong price for rental of 2 bikes 2 hours')
def test_one_bike_three_hours(self): app = Rental('hour', 3, 1) self.assertEqual(app.rent_bikes(), 15, 'Wrong price for rental of 1 bike 3 hours')
continue # Get amount of time (number of hours/days/weeks) while True: try: amount_of_time = int( input(f'For how many {time_unit}s would you like to rent? ')) break except ValueError: print('Not a valid value! Try again') continue # Get number of bikes while True: try: number_of_bikes = int( input('And how many bikes would you like to rent? ')) break except ValueError: print('Not a valid value! Try again') continue # Create an instance (this_rental) of class Rental with the values provided by the user this_rental = Rental(time_unit, amount_of_time, number_of_bikes) # Calculate the price for this rental total_price = this_rental.rent_bikes() # Renturn the total price of the rental to the user print(f'Total price: ${total_price}')