def test_insertBooking(self): with BookingDatabaseUtils(self.connection) as db: count = self.countBooking() self.assertTrue(db.insertBooking(1, 1, '3', 1)) self.assertTrue(count + 1 == self.countBooking()) self.assertTrue(db.insertBooking(1, 1, '3', 1)) self.assertTrue(count + 2 == self.countBooking())
def insertBooking(self, cust_id, car_id, start_date, start_time, end_date, end_time, price, status): with BookingDatabaseUtils() as db: db.insertBooking( cust_id, car_id, start_date, start_time, end_date, end_time, self.getTotalBookingTime(start_date, start_time, end_date, end_time), self.getTotalBookingCost(start_date, start_time, end_date, end_time, price), status)
def test_setBookingDuration(self): with BookingDatabaseUtils(self.connection) as db: bookingID = 4 duration = 1 self.assertTrue(self.bookingExists(bookingID)) self.assertFalse(self.bookingIsDurationValue(bookingID, duration)) db.setBookingDuration(bookingID, duration) self.assertTrue(self.bookingIsDurationValue(bookingID, duration))
def test_cancelBooking(self): with BookingDatabaseUtils(self.connection) as db: count = self.countBooking() bookingID = 1 self.assertTrue(self.bookingExists(bookingID)) db.cancelBooking(bookingID) self.assertFalse(self.bookingExists(bookingID)) self.assertTrue(count - 1 == self.countBooking())
def test_setBookingOngoing(self): with BookingDatabaseUtils(self.connection) as db: bookingID = 4 self.assertTrue(self.bookingExists(bookingID)) self.assertFalse(self.bookingIsOngoing(bookingID)) db.setBookingOngoing(bookingID, 1) self.assertTrue(self.bookingIsOngoing(bookingID)) db.setBookingOngoing(bookingID, 0) self.assertFalse(self.bookingIsOngoing(bookingID))
def getTop10DurationCount(self): with BookingDatabaseUtils() as db: return db.getTop10DurationCount()
def getTop10BookingCountForPrice(self): with BookingDatabaseUtils() as db: return db.getTop10PriceCount()
def getTop10BookingCountForMake(self): with BookingDatabaseUtils() as db: return db.getTop10CarIDCount()
def getTop10Make(self): with BookingDatabaseUtils() as db: return db.getTop10CarID()
def getDurationForGraph(self): with BookingDatabaseUtils() as db: return db.getTop10Duration()
def getBooking(self, booking_id): with BookingDatabaseUtils() as db: return db.getBooking(booking_id)
def cancelBooking(self, bookingID): with BookingDatabaseUtils() as db: db.cancelBooking(bookingID)
def cancelBooking(self, booking_id): with BookingDatabaseUtils() as db: db.updateStatus(2, booking_id)
def listCarBookingHistory(self, carID): with BookingDatabaseUtils() as db: return db.listCarBookingHistory(carID)
def listPersonalOngoingBooking(self, userID): with BookingDatabaseUtils() as db: return db.listPersonalOngoingBooking(userID)
def listPersonalBookingHistory(self, userID): with BookingDatabaseUtils() as db: return db.listPersonalBookingHistory(userID)
def listAllBooking(self): with BookingDatabaseUtils() as db: return db.listAllBooking()
def insertBooking(self, userID, CarID, duration): with BookingDatabaseUtils() as db: db.insertBooking(userID, CarID, duration, 1)
def getPersonalBookingHistory(self, cust_id): with BookingDatabaseUtils() as db: return db.getPersonalBookingHistory(cust_id)
def test_listPersonalOngoingBooking(self): userID = 1 with BookingDatabaseUtils(self.connection) as db: self.assertTrue(self.countOngoingBookingByID(userID) == len(db.listPersonalOngoingBooking(userID)))
def createBookingTable(self): with BookingDatabaseUtils() as db: db.deleteTable() db.createBookingTable()
def getPersonalOngoingBooking(self, cust_id): with BookingDatabaseUtils() as db: return db.getPersonalOngingBooking(cust_id)
def setBookingOngoing(self, bookingID, ongoing): with BookingDatabaseUtils() as db: db.setBookingOngoing(bookingID, ongoing)
def completeBooking(self, booking_id): with BookingDatabaseUtils() as db: db.updateStatus(1, booking_id)
def test_listAllBooking(self): with BookingDatabaseUtils(self.connection) as db: self.assertTrue(self.countBooking() == len(db.listAllBooking()))
def setBookingDuration(self, bookingID, duration): with BookingDatabaseUtils() as db: db.setBookingDuration(bookingID, duration)
def getLatestBookingID(self): with BookingDatabaseUtils() as db: for bookingID in db.getLatestBookingId(): return int(bookingID[0])
def makeBooking(self, cust_id, car_id, start_date, start_time, end_date, end_time, total_time, total_cost): with BookingDatabaseUtils() as db: db.insertBooking(cust_id, car_id, start_date, start_time, end_date, end_time, total_time, total_cost, 0)