def test_park_single_car(self): #prepare park = Park(3) expectedPark = [Car('xxx', 'red'), None, None] #execute park.addCar(Car('xxx', 'red')) #assert self.equalPark(park.park, expectedPark)
def test_park_and_leave(self): #prepare park = Park(5) expectedPark = [ Car('bbb', 'red'), Car('yyy', 'blue'), None, Car('aaa', 'blue'), None ] #execute park.addCar(Car('xxx', 'red')) park.addCar(Car('yyy', 'blue')) park.addCar(Car('zzz', 'green')) park.addCar(Car('aaa', 'blue')) park.leaveCar(1) park.leaveCar(3) park.addCar(Car('bbb', 'red')) #assert self.equalPark(park.park, expectedPark)
def test_park_full(self): #prepare park = Park(3) expectedPark = [ Car('xxx', 'red'), Car('yyy', 'blue'), Car('zzz', 'green') ] #execute park.addCar(Car('xxx', 'red')) park.addCar(Car('yyy', 'blue')) park.addCar(Car('zzz', 'green')) park.addCar(Car('aaa', 'red')) #assert self.equalPark(park.park, expectedPark)
class ParkController: def __init__(self): self.park = None def createPark(self, slotNumber): s = int(slotNumber) self.park = Park(s) output.createdPark(s) def parkCar(self, regNumber, colour): i = self.park.addCar(Car(regNumber, colour)) if (i == -1): output.parkedFail() else: output.parkedSuccessful(i) def leaveCar(self, slotNumber): self.park.leaveCar(slotNumber) output.leaved(slotNumber) def status(self): data = self.park.status() output.status(data) def findSlotNumberWithColour(self, colour): data = self.park.findSlotNumberWithColor(colour) if len(data) == 0: output.findFail() else: output.findSuccessful(data) def findSlotNumberWithRegNumber(self, regNumber): data = self.park.findSlotNumberWithRegNumber(regNumber) if len(data) == 0: output.findFail() else: output.findSuccessful(data) def findRegNumberWithColour(self, colour): data = self.park.findRegNumberWithColor(colour) if len(data) == 0: output.findFail() else: output.findSuccessful(data)
def test_park_multi_car(self): #prepare park = Park(5) expectedPark = [ Car('xxx', 'red'), Car('yyy', 'blue'), Car('zzz', 'green'), None, None ] #execute park.addCar(Car('xxx', 'red')) park.addCar(Car('yyy', 'blue')) park.addCar(Car('zzz', 'green')) #assert self.equalPark(park.park, expectedPark)