Exemplo n.º 1
0
 def testFunctional2(self):
     rental.resetIDCounter()
     rental.setIDCounter(0)
     mvRepo = repo()
     clRepo = repo()
     rtRepo = repo()
     st = store()
     find = finder(clRepo, mvRepo)
     undoC = undoController()
     clc = clientController(clRepo, undoC)
     mvc = movieController(mvRepo, undoC)
     rtc = rentalController(rtRepo, clRepo, mvRepo, st, undoC)
     rmc = removalController(clRepo, mvRepo, rtRepo, undoC, rtc)
     CL = controller(clc, mvc, rtc, rmc, undoC, find)
     with self.assertRaises(Exception):
         CL.undo()
     with self.assertRaises(Exception):
         CL.redo()
     CL.addClient(["1", "Pop Ion"])
     CL.undo()
     CL.redo()
     CL.addMovie(["1", "Titanic", "nice", "Drama"])
     CL.undo()
     CL.redo()
     CL.rent(["1", "1", "11/11/2017", "14/11/2017"])
     CL.removeMovie(["1"])
     CL.undo()
     CL.redo()
     CL.undo()
     CL.removeClient(["1"])
     CL.undo()
     CL.redo()
     CL.undo()
     CL.updateClient(["1", "Pop Viorel"])
     CL.undo()
     CL.redo()
     CL.updateMovie(["1", "Titanic2", "nice", "Drama"])
     CL.undo()
     CL.redo()
     a = CL.getLateRentals(["15/11/2017"])
     CL.Return(["1", "16/11/2017"])
     CL.undo()
     CL.redo()
     CL.addClient(["2", "Ion Ion"])
     CL.addMovie(["2", "Avatar", "nice", "Sci-Fi"])
     CL.rent(["2", "2", "14/11/2017", "15/11/2017"])
     with self.assertRaises(Exception):
         CL.Return(["a", "11/11/2017"])
     a = CL.getMostActive()
     a = CL.getMostRented()
     CL.writeToFile()
Exemplo n.º 2
0
def main():

    clRepo = readFromFile("clientRepo.pickle")
    mvRepo = readFromFile("movieRepo.pickle")
    rtRepo = readFromFile("rentalRepo.pickle")
    st = store()
    find = finder(clRepo, mvRepo)
    undoC = undoController()
    clc = clientController(clRepo, undoC)
    mvc = movieController(mvRepo, undoC)
    rtc = rentalController(rtRepo, clRepo, mvRepo, st, undoC)
    rmc = removalController(clRepo, mvRepo, rtRepo, undoC, rtc)
    CL = controller(clc, mvc, rtc, rmc, undoC, find)
    u = UI(CL)
    u.start()
Exemplo n.º 3
0
 def testFunctional(self):
     rental.resetIDCounter()
     mvRepo = repo()
     clRepo = repo()
     rtRepo = repo()
     st = store()
     find = finder(clRepo, mvRepo)
     undoC = undoController()
     clc = clientController(clRepo, undoC)
     mvc = movieController(mvRepo, undoC)
     rtc = rentalController(rtRepo, clRepo, mvRepo, st, undoC)
     rmc = removalController(clRepo, mvRepo, rtRepo, undoC, rtc)
     CL = controller(clc, mvc, rtc, rmc, undoC, find)
     with self.assertRaises(Exception):
         a = CL.find("1")
     CL.addClient(["1", "Pop Vasile"])
     with self.assertRaises(Exception):
         CL.removeMovie(["ds"])
     CL.addMovie(["1", "Titanic", "nice", "Drama"])
     a = CL.listMovies()
     a = CL.listClients()
     a = CL.listRents("")
     CL.rent(["1", "1", "11/11/2017", "13/11/2017"])
     with self.assertRaises(Exception):
         CL.rent(["1", "1", "11/11/21", "12"])
     with self.assertRaises(Exception):
         CL.rent(["1", "1", "10/11/2017", "11/11/2017"])
     with self.assertRaises(Exception):
         CL.rent(["1", "1", "12/11/2017", "14/11/2017"])
     a = CL.getAllRentals()
     CL.addClient(["10", "Laur"])
     a = str(CL.getAllRentals()[0][0])
     CL.addMovie(["2", "Titanic2", "d", "Drama"])
     with self.assertRaises(Exception):
         CL.rent(["1", "2", "15/11/2017", "16/11/2017"])
     CL.rent(["10", "2", "13/11/2017", "14/11/2017"])
     CL.removeMovie(["2"])
     CL.Return(["1", "14/11/2017"])
     CL.rent(["10", "1", "17/11/2017", "19/11/2017"])
     with self.assertRaises(Exception):
         CL.Return(["1", "13/11/2017"])
     with self.assertRaises(Exception):
         CL.Return(["10", "11/11/2017"])
     with self.assertRaises(Exception):
         CL.rent(["10", "1", "13/11/2017", "16/11/2017"])
     self.assertEqual(str(CL.find("Pop")[0]), str(client("1",
                                                         "Pop Vasile")))
     CL.addClient(["3", "Ion"])
     CL.addMovie(["2", "Titanic2", "Nice", "Drama"])
     a = CL.getAllRentals()
     a = CL.getLateRentals(["13/11/2017"])
     a = CL.getMostActive()
     a = CL.getMostRented()
     a = CL.find("1")
     CL.updateClient(["1", "Pop Viorel"])
     CL.updateMovie(["1", "Titanic2", "nice", "Sci-Fi"])
     CL.addClient(["2", "Ion"])
     CL.removeClient(["1"])
     CL.removeMovie(["1"])
     with self.assertRaises(Exception):
         CL.addMovie("")
     with self.assertRaises(Exception):
         CL.removeMovie("")
     with self.assertRaises(Exception):
         CL.updateMovie("")
     with self.assertRaises(Exception):
         CL.addMovie(["c", "Titanic", "nice", "Romance"])
     with self.assertRaises(Exception):
         CL.removeClient("")
     with self.assertRaises(Exception):
         CL.addClient("")
     with self.assertRaises(Exception):
         CL.updateClient("")
     with self.assertRaises(Exception):
         CL.addClient(["c", "Viorel"])
     with self.assertRaises(Exception):
         CL.rent(["2", "1", "11/11/2017", "11/11/2017"])
     CL.removeClient(["2"])
     with self.assertRaises(Exception):
         CL.rent(["3", "1", "11/11/2017", "13/11/2017"])
     with self.assertRaises(Exception):
         CL.rent(["4", "1", "11/11/2017", "13/11/2017"])
     a = CL._clientController.getRepo()
     a = CL._movieController.getRepo()
     a = CL._rentalController.getRepo()