def executeCommand(parkingLot, command): if command[0] == CREATE_PARKING_LOT: parkingLot = create_parking_lot(command[1]) elif command[0] == PARK_CAR: print(park_car(parkingLot, command[1], command[2])) elif command[0] == CAR_DEPARTURE: print(car_departure(parkingLot, command[1])) elif command[0] == LOT_STATUS: print(lot_status(parkingLot).rstrip('\n')) elif command[0] == SEARCH_SLOT_BY_CAR_NUMBER: print(slot_by_car_number(parkingLot, command[1]).rstrip(', ')) elif command[0] == SEARCH_CAR_BY_COLOUR: print(car_by_colour(parkingLot, command[1]).rstrip(', ')) elif command[0] == SEARCH_SLOT_BY_COLOUR: print(slot_by_colour(parkingLot, command[1]).rstrip(', ')) else: print('Command is not applicable') return parkingLot
def test_slot_by_colour(self): testParkingLot = create_parking_lot(str(6)) testParkString = park_car(testParkingLot, 'KA-01-AA-1119', 'White') testString = slot_by_colour(testParkingLot, 'White') self.assertEqual(testString, '1, ')
def test_car_departure_slot_free(self): testParkingLot = create_parking_lot(str(6)) testParkString = park_car(testParkingLot, 'KA-01-AA-1116', 'White') testString = car_departure(testParkingLot, '2') self.assertEqual('No car at Slot number 2', testString)
def test_slot_by_car_number_not_found(self): testParkingLot = create_parking_lot(str(6)) testParkString = park_car(testParkingLot, 'KA-01-AA-1118', 'White') testString = slot_by_car_number(testParkingLot, 'KA-01-AA-1113') self.assertEqual(testString, 'Not found')
def test_car_departure_cannot_exit(self): testParkingLot = create_parking_lot(str(6)) testParkString = park_car(testParkingLot, 'KA-01-AA-1115', 'White') testString = car_departure(testParkingLot, '7') self.assertEqual('Cannot exit slot: 7 as no such exist!', testString)
def test_car_departure_free(self): testParkingLot = create_parking_lot(str(6)) testParkString = park_car(testParkingLot, 'KA-01-AA-1114', 'White') testString = car_departure(testParkingLot, '1') self.assertEqual('Slot number 1 is free', testString)
def test_park_car_lot_full(self): testParkingLot = create_parking_lot(str(1)) testParkString = park_car(testParkingLot, 'KA-01-AA-1112', 'White') testString = park_car(testParkingLot, 'KA-01-AA-1113', 'White') self.assertEqual('Sorry, parking lot is full', testString)
def test_park_car_lot_allocated(self): testParkingLot = create_parking_lot(str(6)) testString = park_car(testParkingLot, 'KA-01-AA-1112', 'White') self.assertEqual('Allocated slot number: 1', testString)
def test_park_car_lot_not_defined(self): testString = park_car(None, 'KA-01-AA-1111', 'White') self.assertEqual('Parking lot is not defined', testString)