def test_unavailable(): """Tests if bike available status is correctly changed to False""" bikemanager = BikeManager() bike = Bike('AAA', BikeType.BMX, BikeBrand.GIANT, True) bikemanager.unavailable(bike) assert bike.available == False
def test_get_bike_notok2(): """Tests if a bike that does not exist can be rented""" bikemanager = BikeManager() bike = Bike('AAA', BikeType.BMX, BikeBrand.GIANT, True) bikemanager.add_bike(bike) rentedbike = bikemanager.get_bike(BikeType.COMMUTING) assert isinstance(rentedbike, Bike) == False
def test_get_bike_notok1(): """Tests if a bike not available can be rented""" bikemanager = BikeManager() bike = Bike('AAA', BikeType.BMX, BikeBrand.GIANT, False) bikemanager.add_bike(bike) rentedbike = bikemanager.get_bike(BikeType.BMX) assert isinstance(rentedbike, Bike) == False
def test_available(): """Tests if bike available status is correctly changed to true""" bikemanager = BikeManager() bike = Bike('AAA', BikeType.BMX, BikeBrand.GIANT, False) logging.warning('Created bike: ' + str(bike)) bikemanager.available(bike) logging.warning('Bike available property changed to True') assert bike.available == True
def test_add_bike_ok(): """Tests if a bike is added correctly to the manager""" bikemanager = BikeManager() bike = Bike('AAA', BikeType.BMX, BikeBrand.GIANT, True) size = len(bikemanager.bikes) bikemanager.add_bike(bike) newsize = len(bikemanager.bikes) assert (newsize < size) == False
def test_create_rent_ok(): rent_manager = RentManager() customer_manager = CustomerManager() customer = customer_manager.create_customer('35025191', 'Julian', 'Massolo', 'Mitre 182', '*****@*****.**', '222225', []) bike = Bike('AAA', BikeType.BMX, BikeBrand.GIANT, True) rent_manager.bikemanager.add_bike(bike) rent = rent_manager.create_rent('01/01/2019', '05/01/2019', RentType.DAY, customer, BikeType.BMX) assert isinstance(rent, Rent) == True
def unavailable(self, bike: Bike): """Sets a bike's available property to False""" logging.info('Changing bike availability to false') bike.available = False
def available(self, bike: Bike): """Sets a bike's available property to True""" logging.info('Changing bike availability to true') bike.available = True