def test_status(self): """ test status """ oParking = Parking(3) sMessage = oParking.status() self.assertEquals(sMessage, "Slot No.\tRegistration No\t\tColour\n") oParking.lSlot[0] = Slot("1234", "123") sMessage = oParking.status() self.assertEquals( sMessage, "Slot No.\tRegistration No\t\tColour\n1\t\t1234\t\t\t123\n") oParking.lSlot[2] = Slot("1234", "123") sMessage = oParking.status() self.assertEquals( sMessage, "Slot No.\tRegistration No\t\tColour\n1\t\t1234\t\t\t123\n3\t\t1234\t\t\t123\n" )
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()