コード例 #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())
コード例 #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)
コード例 #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
コード例 #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())
コード例 #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))
コード例 #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)
コード例 #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))
コード例 #8
0
ファイル: mainEngine.py プロジェクト: s3665858/IoT-A3
 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)
コード例 #9
0
ファイル: mainEngine.py プロジェクト: s3665858/IoT-A3
 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))
コード例 #10
0
ファイル: mainEngine.py プロジェクト: s3665858/IoT-A3
 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)
コード例 #11
0
ファイル: mainEngine.py プロジェクト: s3665858/IoT-A3
 def listBrokenCars(self):
     with CarDatabaseUtils() as db:
         return db.listBrokenCars()
コード例 #12
0
 def test_searchCarsbyMake(self):
     with CarDatabaseUtils(self.connection) as db:
         make = 'Lamborghini'
         self.assertTrue(self.countCarsWithMake(make) == len(db.searchCarsbyMake(make)))
コード例 #13
0
ファイル: mainEngine.py プロジェクト: s3665858/IoT-A3
 def getTop10Price(self):
     with CarDatabaseUtils() as db:
         return db.getTop10Price()
コード例 #14
0
ファイル: mainEngine.py プロジェクト: s3665858/IoT-A3
 def setCarAvailability(self, CarID, Availability):
     with CarDatabaseUtils() as db:
         db.setCarAvailability(CarID, Availability)
コード例 #15
0
ファイル: mainEngine.py プロジェクト: s3665858/IoT-A3
 def getCarDetails(self, CarID):
     with CarDatabaseUtils() as db:
         return db.getCarDetails(int(CarID))
コード例 #16
0
 def deleteCar(self, car_id):
     with CarDatabaseUtils() as db:
         db.deleteCar(car_id)
コード例 #17
0
 def test_searchCarsbyCost(self):
     with CarDatabaseUtils(self.connection) as db:
         cost = 5
         self.assertTrue(self.countCarsWithCost(cost) == len(db.searchCarsbyCost(cost)))
コード例 #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)))
コード例 #19
0
 def test_searchCarsbySeats(self):
     with CarDatabaseUtils(self.connection) as db:
         seats = 2
         self.assertTrue(self.countCarsWithSeats(seats) == len(db.searchCarsbySeats(seats)))
コード例 #20
0
 def test_searchCarsbyColour(self):
     with CarDatabaseUtils(self.connection) as db:
         colour = 'Orange'
         self.assertTrue(self.countCarsWithColour(colour) == len(db.searchCarsbyColour(colour)))
コード例 #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)))
コード例 #22
0
 def getCar(self, car_id):
     with CarDatabaseUtils() as db:
         return db.getCar(car_id)
コード例 #23
0
ファイル: mainEngine.py プロジェクト: s3665858/IoT-A3
 def getCar(self, CarID):
     with CarDatabaseUtils() as db:
         for car in db.listCars():
             if car[0] == CarID:
                 return car
コード例 #24
0
 def setCarUnavalaible(self, car_id):
     with CarDatabaseUtils() as db:
         db.updateStatus(1, car_id)
コード例 #25
0
ファイル: mainEngine.py プロジェクト: s3665858/IoT-A3
 def deleteCar(self, CarID):
     with CarDatabaseUtils() as db:
         db.deleteCar(int(CarID))
コード例 #26
0
 def getAvalaibleCars(self):
     with CarDatabaseUtils() as db:
         return db.getAllAvalaibleCars()
コード例 #27
0
ファイル: mainEngine.py プロジェクト: s3665858/IoT-A3
 def setCarLocation(self, CarID, location):
     with CarDatabaseUtils() as db:
         db.setCarLocation(CarID, location)
コード例 #28
0
ファイル: mainEngine.py プロジェクト: s3665858/IoT-A3
 def listAvailableCars(self):
     with CarDatabaseUtils() as db:
         return db.listAvailableCars()
コード例 #29
0
 def createCarTable(self):
     with CarDatabaseUtils() as db:
         db.deleteTable()
         db.createCarTable()
コード例 #30
0
 def test_listAvailableCars(self):
     with CarDatabaseUtils(self.connection) as db:
         self.assertTrue(self.countAvailableCars() == len(db.listAvailableCars()))