def test_carsWithColor(self): """ test cars with Color check output after insert and delete to be excepted """ oParking = Parking(2) sMessage = oParking.carsWithColor("white") self.assertEquals("", "") oParking.addCar("12", "white") sMessage = oParking.carsWithColor("white") self.assertEquals(sMessage, "12") oParking.addCar("13", "black") sMessage = oParking.carsWithColor("white") self.assertEquals(sMessage, "12") oParking.removeCar(1) sMessage = oParking.carsWithColor("white") self.assertEquals(sMessage, "")
def test_removeCar(self): """ test removeCar test if slot number greater than no of slots check for non zero slot """ oParking = Parking(0) sMessage = oParking.removeCar(1) self.assertEquals(sMessage, "There is no Slot number {}".format(1)) oParking = Parking(2) sMessage = oParking.removeCar(2) self.assertEquals(sMessage, "Slot number {} is free".format(2)) oParking.addCar("12", "white") oParking.addCar("13", "black") sMessage = oParking.removeCar(2) self.assertFalse("black" in oParking.dCarsColor) self.assertEquals(sMessage, "Slot number {} is free".format(2))
def test_slotNumber(self): """ test slot Number of car check output after insert and delete to be excepted """ oParking = Parking(2) sMessage = oParking.carsWithColor("white") self.assertEquals("", "") oParking.addCar("12", "white") sMessage = oParking.slotNumber("12") self.assertEquals(sMessage, "1") oParking.addCar("13", "black") sMessage = oParking.slotNumber("12") self.assertEquals(sMessage, "1") oParking.removeCar(1) sMessage = oParking.slotNumber("12") self.assertEquals(sMessage, "None Found") sMessage = oParking.slotNumber("13") self.assertEquals(sMessage, "2")
input_file = open(sys.argv[1], 'r') getCommand = input_file.readline else: getCommand = raw_input if bInteractive: print "Input:" sCommand = getCommand() while sCommand: lCommands = sCommand.split() iLength = len(lCommands) if iLength: if bInteractive: print "\nOutput:" if lCommands[0] == "create_parking_lot" and iLength == 2: oParking = Parking(int(lCommands[1])) elif lCommands[0] == "park" and iLength == 3: print oParking.addCar(lCommands[1], lCommands[2]) + "\n" elif lCommands[0] == "leave" and iLength == 2: print oParking.removeCar(int(lCommands[1])) + "\n" elif lCommands[0] == "status": print oParking.status() elif lCommands[ 0] == "registration_numbers_for_cars_with_colour" and iLength == 2: print oParking.carsWithColor(lCommands[1]) + "\n" elif lCommands[ 0] == "slot_number_for_registration_number" and iLength == 2: print oParking.slotNumber(lCommands[1]) + "\n" if bInteractive: print "Input:" sCommand = getCommand()