Esempio n. 1
0
 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())
Esempio n. 2
0
 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)
Esempio n. 3
0
 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
Esempio n. 4
0
    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())
Esempio n. 5
0
    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))
Esempio n. 6
0
 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)
Esempio n. 7
0
    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))
Esempio n. 8
0
 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)
Esempio n. 9
0
 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))
Esempio n. 10
0
 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)
Esempio n. 11
0
 def listBrokenCars(self):
     with CarDatabaseUtils() as db:
         return db.listBrokenCars()
Esempio n. 12
0
 def test_searchCarsbyMake(self):
     with CarDatabaseUtils(self.connection) as db:
         make = 'Lamborghini'
         self.assertTrue(self.countCarsWithMake(make) == len(db.searchCarsbyMake(make)))
Esempio n. 13
0
 def getTop10Price(self):
     with CarDatabaseUtils() as db:
         return db.getTop10Price()
Esempio n. 14
0
 def setCarAvailability(self, CarID, Availability):
     with CarDatabaseUtils() as db:
         db.setCarAvailability(CarID, Availability)
Esempio n. 15
0
 def getCarDetails(self, CarID):
     with CarDatabaseUtils() as db:
         return db.getCarDetails(int(CarID))
Esempio n. 16
0
 def deleteCar(self, car_id):
     with CarDatabaseUtils() as db:
         db.deleteCar(car_id)
Esempio n. 17
0
 def test_searchCarsbyCost(self):
     with CarDatabaseUtils(self.connection) as db:
         cost = 5
         self.assertTrue(self.countCarsWithCost(cost) == len(db.searchCarsbyCost(cost)))
Esempio n. 18
0
 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)))
Esempio n. 19
0
 def test_searchCarsbySeats(self):
     with CarDatabaseUtils(self.connection) as db:
         seats = 2
         self.assertTrue(self.countCarsWithSeats(seats) == len(db.searchCarsbySeats(seats)))
Esempio n. 20
0
 def test_searchCarsbyColour(self):
     with CarDatabaseUtils(self.connection) as db:
         colour = 'Orange'
         self.assertTrue(self.countCarsWithColour(colour) == len(db.searchCarsbyColour(colour)))
Esempio n. 21
0
 def test_searchCarsbyType(self):
     with CarDatabaseUtils(self.connection) as db:
         body_type = 'Coupe'
         self.assertTrue(self.countCarsWithBodyType(body_type) == len(db.searchCarsbyType(body_type)))
Esempio n. 22
0
 def getCar(self, car_id):
     with CarDatabaseUtils() as db:
         return db.getCar(car_id)
Esempio n. 23
0
 def getCar(self, CarID):
     with CarDatabaseUtils() as db:
         for car in db.listCars():
             if car[0] == CarID:
                 return car
Esempio n. 24
0
 def setCarUnavalaible(self, car_id):
     with CarDatabaseUtils() as db:
         db.updateStatus(1, car_id)
Esempio n. 25
0
 def deleteCar(self, CarID):
     with CarDatabaseUtils() as db:
         db.deleteCar(int(CarID))
Esempio n. 26
0
 def getAvalaibleCars(self):
     with CarDatabaseUtils() as db:
         return db.getAllAvalaibleCars()
Esempio n. 27
0
 def setCarLocation(self, CarID, location):
     with CarDatabaseUtils() as db:
         db.setCarLocation(CarID, location)
Esempio n. 28
0
 def listAvailableCars(self):
     with CarDatabaseUtils() as db:
         return db.listAvailableCars()
Esempio n. 29
0
 def createCarTable(self):
     with CarDatabaseUtils() as db:
         db.deleteTable()
         db.createCarTable()
Esempio n. 30
0
 def test_listAvailableCars(self):
     with CarDatabaseUtils(self.connection) as db:
         self.assertTrue(self.countAvailableCars() == len(db.listAvailableCars()))