Esempio n. 1
0
    def __test_stergere_inchirieri_dupa_film(self):
        self.__repoFilm = RepoFilm()
        self.__repoFilm.adauga(film(3, "titlu1", "descr 1", "gen1"))
        self.__repoFilm.adauga(film(4, "titlu2", "descr 2", "gen2"))
        self.__repoFilm.adauga(film(5, "titlu3", "descr 3", "gen3"))

        self.__repoClient = RepoClient()
        self.__repoClient.adauga(client(5, "andrei1", "123567345998"))
        self.__repoClient.adauga(client(6, "andrei2", "123567345999"))
        self.__repoClient.adauga(client(7, "andrei3", "123567345900"))

        self.__repoInchiriere = RepoInchiriere()
        self.__inchiriere = inchiriere(5, 3, 0)
        self.__repoInchiriere.adauga(self.__inchiriere)
        self.__repoInchiriere.adauga(inchiriere(6, 5, 1))
        self.__repoInchiriere.adauga(inchiriere(7, 5, 0))
        self.assertEqual(self.__repoInchiriere.size(), 3)

        repoInchiriere = self.__repoInchiriere
        self.__serviceInchirieri = ServiceInchiriere(repoInchiriere,
                                                     self.__validareInchirieri,
                                                     self.__repoFilm,
                                                     self.__repoClient)
        self.__serviceInchirieri.sterge_dupa_filme(5)

        self.assertEqual(self.__repoInchiriere.size(), 1)
        inchirierile = self.__repoInchiriere.get_all()
        self.assertEqual(inchirierile, [self.__inchiriere])
Esempio n. 2
0
    def __test_valideaza_inchiriere(self):
        validInchirieri = ValidareInchiriere()
        validInchirieri.valideaza_inchiriere(self.__inchiriere)
        self.__inchiriere_idFilm_rau = inchiriere(9, -3, 1)
        self.__inchiriere_idClient_rau = inchiriere(-9, 3, 1)
        self.__inchiriere_status_rau = inchiriere(9, 3, 2)
        self.__inchiriere_rea = inchiriere(-9, -3, -1)

        with self.assertRaises(ValidError) as eroare:
            validInchirieri.valideaza_inchiriere(self.__inchiriere_idFilm_rau)
        eroarea = str(eroare.exception)
        self.assertEqual(eroarea, "Id-ul filmului este invalid!\n")

        with self.assertRaises(ValidError) as eroare:
            validInchirieri.valideaza_inchiriere(
                self.__inchiriere_idClient_rau)
        eroarea = str(eroare.exception)
        self.assertEqual(eroarea, "Id-ul clientului este invalid!\n")

        with self.assertRaises(ValidError) as eroare:
            validInchirieri.valideaza_inchiriere(self.__inchiriere_status_rau)
        eroarea = str(eroare.exception)
        self.assertEqual(eroarea, "Stare de returnare invalida!\n")

        with self.assertRaises(ValidError) as eroare:
            validInchirieri.valideaza_inchiriere(self.__inchiriere_rea)
        eroarea = str(eroare.exception)
        self.assertEqual(
            eroarea,
            "Id-ul clientului este invalid!\nId-ul filmului este invalid!\nStare de returnare invalida!\n"
        )
        self.__validareInchirieri = validInchirieri
Esempio n. 3
0
    def __test_adaugare_Inchiriere(self):
        self.__repoFilm = RepoFilm()
        self.__repoFilm.adauga(
            film(3, "morometii", "o descriere frumoasa", "documentar"))

        self.__repoClient = RepoClient()
        self.__repoClient.adauga(client(5, "andrei", "123567345987"))

        repoInchiriere = RepoInchiriere()
        self.__serviceInchirieri = ServiceInchiriere(repoInchiriere,
                                                     self.__validareInchirieri,
                                                     self.__repoFilm,
                                                     self.__repoClient)
        self.__repoInchiriere = RepoInchiriere()
        self.assertEqual(self.__repoInchiriere.size(), 0)
        self.__serviceInchirieri.add_inchiriere(5, 3, 0)
        self.__inchiriere = inchiriere(5, 3, 0)
        self.__repoInchiriere.adauga(self.__inchiriere)
        self.assertEqual(self.__repoInchiriere.size(), 1)

        with self.assertRaises(RepoError) as eroare:
            self.__serviceInchirieri.add_inchiriere(3, 5, 0)
        eroarea = str(eroare.exception)
        self.assertEqual(eroarea, "Id inexistent!\n")

        inchirierile = self.__repoInchiriere.get_all()
        self.assertEqual(inchirierile, [self.__inchiriere])
Esempio n. 4
0
    def add_inchiriere(self, idClient, idFilm, stare):
        self.__repoClienti.cauta(idClient)
        self.__repoFilme.cauta(idFilm)

        inchirierea = inchiriere(idClient, idFilm, stare)
        self.__validInchiriere.valideaza_inchiriere(inchirierea)
        self.__repoInchirieri.adauga(inchirierea)
Esempio n. 5
0
    def __test_actualizare_Inchiriere(self):
        self.__repoInchiriere = RepoInchiriere()
        self.__repoInchiriere.adauga(inchiriere(5, 10, 0))
        self.__repoInchiriere.adauga(inchiriere(3, 6, 0))
        self.__repoInchiriere.actualizeaza(inchiriere(3, 6, 1))
        self.assertEqual(self.__repoInchiriere.get_stare(3, 6), 1)
        self.__repoInchiriere.actualizeaza(inchiriere(5, 10, 1))
        self.assertEqual(self.__repoInchiriere.get_stare(5, 10), 1)

        self.__serviceInchiriere = ServiceInchiriere(self.__repoInchiriere,
                                                     self.__validareInchirieri,
                                                     self.__repoFilm,
                                                     self.__repoClient)
        with self.assertRaises(RepoError) as eroare:
            self.__serviceInchiriere.update_inchiriere(200, 56)
        eroarea = str(eroare.exception)
        self.assertEqual(eroarea, "Inchiriere inexistenta!\n")
Esempio n. 6
0
 def __test_creeaza_inchiriere(self):
     idClient = 21
     idFilm = 12
     stareRetur = 0
     inchirierea = inchiriere(idClient, idFilm, stareRetur)
     self.assertTrue(inchirierea.getFilmId() == 12)
     self.assertTrue(inchirierea.getClientId() == 21)
     self.assertTrue(inchirierea.getStareRetur() == 0)
     inchirierea.setFilmId(14)
     self.assertTrue(inchirierea.getFilmId() == 14)
     self.__inchiriere = inchirierea
Esempio n. 7
0
    def __test_get_gen_totalInchirieri(self):
        self.__repoFilm = RepoFilm()
        self.__repoFilm.adauga(film(3, "titlu1", "descr 1", "gen1"))
        self.__repoFilm.adauga(film(4, "titlu2", "descr 2", "gen2"))
        self.__repoFilm.adauga(film(5, "titlu3", "descr 3", "gen3"))

        self.__repoClient = RepoClient()
        self.__repoClient.adauga(client(5, "andrei1", "123567345998"))
        self.__repoClient.adauga(client(6, "andrei2", "123567345999"))
        self.__repoClient.adauga(client(7, "andrei3", "123567345900"))

        self.__repoInchiriere = RepoInchiriere()
        self.__repoInchiriere.adauga(inchiriere(5, 3, 0))
        self.__repoInchiriere.adauga(inchiriere(6, 5, 1))
        self.__repoInchiriere.adauga(inchiriere(6, 4, 0))
        self.__repoInchiriere.adauga(inchiriere(7, 4, 0))
        self.__repoInchiriere.adauga(inchiriere(5, 4, 0))
        self.__repoInchiriere.adauga(inchiriere(6, 5, 0))

        repoInchiriere = self.__repoInchiriere
        self.__serviceInchirieri = ServiceInchiriere(repoInchiriere,
                                                     self.__validareInchirieri,
                                                     self.__repoFilm,
                                                     self.__repoClient)
        lista = self.__serviceInchirieri.get_gen_totalInchirieri()
        self.assertEqual(lista, [["gen1", 1], ["gen2", 3], ["gen3", 2]])
Esempio n. 8
0
    def update_inchiriere(self, idClient, idFilm):
        self.__repoInchirieri.cauta(idClient, idFilm)

        inchirierea = inchiriere(idClient, idFilm, 1)
        self.__validInchiriere.valideaza_inchiriere(inchirierea)
        self.__repoInchirieri.actualizeaza(inchirierea)