Пример #1
0
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
Пример #2
0
 def test_car_departure_not_defined(self):
     testString = car_departure(None, '1')
     self.assertEqual('Parking lot is not defined', testString)
Пример #3
0
 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)
Пример #4
0
 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)
Пример #5
0
 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)
Пример #6
0
 def test_car_departure_empty(self):
     testParkingLot = create_parking_lot(str(6))
     testString = car_departure(testParkingLot, '1')
     self.assertEqual('Sorry, parking lot is empty', testString)