def testadd(self): p = PlaneRepo() p1 = Passengers('Ion', 'Popescu', 1) p2 = Passengers('Ioana', 'Popescu', 2) p3 = Planes('Nume', 'A101', 'Wizair', 60, 'Cairo', [p1, p2]) p.addPlane(p3) self.assertEqual(p.lenPlanes(), 1)
def testUpdate(self): p = PassengersRepo() p.addPassenger(Passengers('Ion','Popescu',340)) p.addPassenger(Passengers('Ioana','Pop',10)) p.updateFirstName('Andrei', 1) p.updateLastName('Ln', 1) p.updatePassportNumber(30, 0) self.assertEqual(p[0].getpassportNr(),30) self.assertEqual(p[1].getFirstName(),'Andrei') self.assertEqual(p[1].getLastName(), 'Ln')
def testFind2(self): pr1 = PassengersRepo() pr2 = PlaneRepo() ctrl = Controller(pr2, pr1) p1 = Passengers('Ion', 'C', 'abc') p2 = Passengers('Ioana', 'B', 'abc2') p3 = Planes('Nume', 'A101', 'Wizair', 60, 'Cairo', [p1, p2]) ctrl.addPlane(p3) p4 = Passengers('Ion', 'A', 'abc22') p5 = Passengers('Andrei', 'B', 'adc44') p6 = Planes('Nume1', 'A202', 'Wizz', 60, 'Cairo', [p4, p5]) ctrl.addPlane(p6)
def testSort3(self): pr1 = PassengersRepo() pr2 = PlaneRepo() ctrl = Controller(pr2, pr1) p1 = Passengers('Ion', 'C', '1') p2 = Passengers('Ioana', 'B', '1') p3 = Planes('Nume', 'A101', 'Wizair', 60, 'Cairo', [p1, p2]) ctrl.addPlane(p3) p4 = Passengers('Ion', 'A', '1') p6 = Planes('Nume1', 'A202', 'Wizz', 1, 'Cairo', [p4]) ctrl.addPlane(p6) ctrl.sortwithconcatenation() self.assertEqual(ctrl.getPlanesforTest(), [p6, p3])
def testSort2(self): pr1 = PassengersRepo() pr2 = PlaneRepo() ctrl = Controller(pr2, pr1) p1 = Passengers('Ion', 'C', '1') p2 = Passengers('Ioana', 'B', '2') p3 = Planes('Nume', 'A101', 'Wizair', 60, 'Cairo', [p1, p2]) ctrl.addPlane(p3) p4 = Passengers('Ion', 'A', '1') p5 = Passengers('Andrei', 'B', '2') p6 = Planes('Nume1', 'A202', 'Wizz', 60, 'Cairo', [p4, p5]) ctrl.addPlane(p6) ctrl.sortwithletter('I') self.assertEqual(ctrl.getPlanesforTest(), [p6, p3])
def testSort1(self): pr1 = PassengersRepo() pr2 = PlaneRepo() ctrl = Controller(pr2, pr1) p1 = Passengers('Ion', 'C', '1') p2 = Passengers('Ioana', 'B', '2') p3 = Planes('Nume', 'A101', 'Wizair', 60, 'Cairo', [p1, p2]) ctrl.addPlane(p3) p4 = Passengers('Ion', 'A', '1') p5 = Passengers('Ioana', 'B', '2') p6 = Planes('Nume1', 'A202', 'Wizz', 60, 'Cairo', [p4, p5]) ctrl.addPlane(p6) ctrl.sortbyLastName() self.assertEqual(ctrl.getPlanes()[0].getPassengers(), [p2, p1]) self.assertEqual(ctrl.getPlanes()[1].getPassengers(), [p4, p5])
def testUpdate(self): p = PlaneRepo() p1 = Passengers('Ion', 'Popescu', 1) p2 = Passengers('Ioana', 'Popescu', 2) p3 = Planes('Nume', 'A101', 'Wizair', 60, 'Cairo', [p1, p2]) p.addPlane(p3) p.updateName('Nume1', 0) p.updateNumber('A103', 0) p.updateCompany('Wizz', 0) p.updateSeats(100, 0) p.updateDestination('Lima', 0) self.assertEqual(p[0].getName(), 'Nume1') self.assertEqual(p[0].getNumber(), 'A103') self.assertEqual(p[0].getAirlineCompany(), 'Wizz') self.assertEqual(p[0].getNumberOfSeats(), 100) self.assertEqual(p[0].getDestination(), 'Lima')
def testBT2(self): pr1 = PassengersRepo() pr2 = PlaneRepo() ctrl = Controller(pr2, pr1) p1 = Passengers('Ion', 'C', 'abc') p2 = Passengers('Ioana', 'B', 'abc2') p3 = Planes('Nume1', 'A201', 'Wizair', 60, 'Cairo', [p1, p2]) ctrl.addPlane(p3) p4 = Passengers('Ion', 'A', 'abc22') p5 = Passengers('Andrei', 'B', 'adc44') p6 = Planes('Nume2', 'A202', 'Wizair', 60, 'Cairo', [p4, p5]) ctrl.addPlane(p6) p7 = Planes('Nume3', 'A203', 'Wair', 60, 'Cairo', [p4, p5]) ctrl.addPlane(p7) p8 = Planes('Nume4', 'A204', 'Wizair', 60, 'Cairo', [p4, p5]) ctrl.addPlane(p8) l1 = ctrl.form2(2)
def testGettersSetters(self): p1 = Passengers('Ion','Popescu',1) p2 = Passengers('Ioana','Popescu',2) p = Planes('Nume','A101','Wizair',60,'Cairo',[p1,p2]) self.assertEqual(p.getName(), 'Nume') self.assertEqual(p.getNumber(), 'A101') self.assertEqual(p.getAirlineCompany(), 'Wizair') self.assertEqual(p.getNumberOfSeats(), 60) self.assertEqual(p.getDestination(), 'Cairo') self.assertEqual(p.getPassengers(), [p1,p2]) p.setName('Nume1') p.setNumber('A102') p.setAirlineCompany('Wizz') p.setNumberOfSeats(30) p.setDestination('Lima') p.setPassengers([p2,p1]) self.assertEqual(p.getName(), 'Nume1') self.assertEqual(p.getNumber(), 'A102') self.assertEqual(p.getAirlineCompany(), 'Wizz') self.assertEqual(p.getNumberOfSeats(), 30) self.assertEqual(p.getDestination(), 'Lima') self.assertEqual(p.getPassengers(), [p2,p1])
def addPassengerinPlane(self, fname, lname, pnr, number, company): ''' We add a passenger in a plane ''' p = Passengers(fname, lname, pnr) l1 = self.__passengerrepo.lenPassengers() self.__passengerrepo.addPassenger(p) l2 = self.__passengerrepo.lenPassengers() if l1 == l2: return None for i in range(self.__planerepo.lenPlanes()): if self.__planerepo[i].getNumber( ) == number and self.__planerepo[i].getAirlineCompany() == company: l = self.__planerepo[i].getPassengers() l.append(p) self.__planerepo[i].setPassengers(l) return None
def testDelete(self): p = PassengersRepo() p.addPassenger(Passengers('Ion','Popescu',340)) p.deleteLastPassenger() self.assertEqual(p.lenPassengers(), 0)
def testadd(self): p = PassengersRepo() p.addPassenger(Passengers('Ion','Popescu',340)) self.assertEqual(p.lenPassengers(), 1)
def testGetersAndSeters(self): p = Passengers('Ion', 'Pop', 33) self.assertEqual(p.getFirstName(), 'Ion') self.assertEqual(p.getLastName(), 'Pop') self.assertEqual(p.getpassportNr(), 33) p.setFirstName('Ioana') p.setLastName('Popescu') p.setpassportNr('100423') self.assertEqual(p.getFirstName(), 'Ioana') self.assertEqual(p.getLastName(), 'Popescu') self.assertEqual(p.getpassportNr(), '100423')