def test_insertCar(self): with CarDatabaseUtils(self.connection) as db: count = self.countCar() self.assertTrue(db.insertCar('Lamborghini', 'Coupe', 'Orange', 2, 'MelbourneCBD,-37.000.142.000', 5, 1)) self.assertTrue(count + 1 == self.countCar()) self.assertTrue(db.insertCar('Ferrari', 'Coupe', 'Red', 2, 'MelbourneCBD,-37.000.142.000', 15, 1)) self.assertTrue(count + 2 == self.countCar())
def editCar(self, car_id, name, colour, description, capacity, registration_plate, fuel_type, transmission, type_, longitude, latitude, image): with CarDatabaseUtils() as db: db.editCar(car_id, name, colour, description, capacity, registration_plate, fuel_type, transmission, type_, self.regularCarPrice(capacity, fuel_type, transmission), longitude, latitude, image)
def editCarRegistrationValidation(self, registration_plate, car_id): valid = True with CarDatabaseUtils() as db: cars = db.getAllCarExceptId(car_id) for car in cars: if car[5].lower() == registration_plate.lower(): valid = False break return valid
def test_deleteCar(self): with CarDatabaseUtils(self.connection) as db: count = self.countCar() carID = 1 self.assertTrue(self.carExists(carID)) db.deleteCar(carID) self.assertFalse(self.carExists(carID)) self.assertTrue(count - 1 == self.countCar())
def test_setCarLocation(self): with CarDatabaseUtils(self.connection) as db: carID = 1 location = 'Sydney,-37.000.142.000' self.assertTrue(self.carExists(carID)) self.assertFalse(self.carHasLocation(carID, location)) db.setCarLocation(carID, location) self.assertTrue(self.carHasLocation(carID, location))
def searchCars(self, column, search): with CarDatabaseUtils() as db: if column == 'name': return db.searchCarsName(search) elif column == 'type': return db.searchCarsType(search) elif column == 'colour': return db.searchCarsColour(search) elif column == 'fuel_type': return db.searchCarsFuel(search) elif column == 'transmission': return db.searchCarsTransmission(search)
def test_setCarAvailability(self): with CarDatabaseUtils(self.connection) as db: carID = 1 self.assertTrue(self.carExists(carID)) self.assertTrue(self.carIsAvailable(carID)) db.setCarAvailability(carID, 0) self.assertFalse(self.carIsAvailable(carID)) db.setCarAvailability(carID, 1) self.assertTrue(self.carIsAvailable(carID))
def searchCars(self, column, search): with CarDatabaseUtils() as db: if column == "make": return db.searchCarsbyMake( search.lower()) #.lower() makes it lowercase elif column == "body_type": return db.searchCarsbyType(search.lower()) elif column == "colour": return db.searchCarsbyColour(search.lower()) elif column == "seats": return db.searchCarsbySeats(search) elif column == "location": return db.searchCarsbyLocation(search.lower()) elif column == "cost": return db.searchCarsbyCost(search)
def updateCar(self, carID, name, bodytype, colour, seats, location, cost, availibility): with CarDatabaseUtils() as db: db.updateCar(carID, name, bodytype, colour, int(seats), location, int(cost), int(availibility))
def insertCar(self, make, body_type, colour, seats, location, cost_per_hour): with CarDatabaseUtils() as db: db.insertCar(make, body_type, colour, int(seats), location, int(cost_per_hour), 1)
def listBrokenCars(self): with CarDatabaseUtils() as db: return db.listBrokenCars()
def test_searchCarsbyMake(self): with CarDatabaseUtils(self.connection) as db: make = 'Lamborghini' self.assertTrue(self.countCarsWithMake(make) == len(db.searchCarsbyMake(make)))
def getTop10Price(self): with CarDatabaseUtils() as db: return db.getTop10Price()
def setCarAvailability(self, CarID, Availability): with CarDatabaseUtils() as db: db.setCarAvailability(CarID, Availability)
def getCarDetails(self, CarID): with CarDatabaseUtils() as db: return db.getCarDetails(int(CarID))
def deleteCar(self, car_id): with CarDatabaseUtils() as db: db.deleteCar(car_id)
def test_searchCarsbyCost(self): with CarDatabaseUtils(self.connection) as db: cost = 5 self.assertTrue(self.countCarsWithCost(cost) == len(db.searchCarsbyCost(cost)))
def test_searchCarsbyLocation(self): with CarDatabaseUtils(self.connection) as db: location = 'MelbourneCBD,-37.000.142.000' self.assertTrue(self.countCarsWithLocation(location) == len(db.searchCarsbyLocation(location)))
def test_searchCarsbySeats(self): with CarDatabaseUtils(self.connection) as db: seats = 2 self.assertTrue(self.countCarsWithSeats(seats) == len(db.searchCarsbySeats(seats)))
def test_searchCarsbyColour(self): with CarDatabaseUtils(self.connection) as db: colour = 'Orange' self.assertTrue(self.countCarsWithColour(colour) == len(db.searchCarsbyColour(colour)))
def test_searchCarsbyType(self): with CarDatabaseUtils(self.connection) as db: body_type = 'Coupe' self.assertTrue(self.countCarsWithBodyType(body_type) == len(db.searchCarsbyType(body_type)))
def getCar(self, car_id): with CarDatabaseUtils() as db: return db.getCar(car_id)
def getCar(self, CarID): with CarDatabaseUtils() as db: for car in db.listCars(): if car[0] == CarID: return car
def setCarUnavalaible(self, car_id): with CarDatabaseUtils() as db: db.updateStatus(1, car_id)
def deleteCar(self, CarID): with CarDatabaseUtils() as db: db.deleteCar(int(CarID))
def getAvalaibleCars(self): with CarDatabaseUtils() as db: return db.getAllAvalaibleCars()
def setCarLocation(self, CarID, location): with CarDatabaseUtils() as db: db.setCarLocation(CarID, location)
def listAvailableCars(self): with CarDatabaseUtils() as db: return db.listAvailableCars()
def createCarTable(self): with CarDatabaseUtils() as db: db.deleteTable() db.createCarTable()
def test_listAvailableCars(self): with CarDatabaseUtils(self.connection) as db: self.assertTrue(self.countAvailableCars() == len(db.listAvailableCars()))