Esempio n. 1
0
    def __test_valideaza_client(self):
        validClienti = ValidareClient()
        validClienti.valideaza_client(self.__client)
        self.__client_id_rau = client(-31, "Ionica", "128913046712")
        self.__client_nume_rau = client(31, "", "125783902135")
        self.__client_cnp_rau = client(32, "Georgel", "")
        self.__client_rau = client(-31, "", "")

        with self.assertRaises(ValidError) as eroare:
            validClienti.valideaza_client(self.__client_id_rau)
        eroarea = str(eroare.exception)
        self.assertEqual(eroarea, "Id invalid!\n")

        with self.assertRaises(ValidError) as eroare:
            validClienti.valideaza_client(self.__client_nume_rau)
        eroarea = str(eroare.exception)
        self.assertEqual(eroarea, "Nume invalid!\n")

        with self.assertRaises(ValidError) as eroare:
            validClienti.valideaza_client(self.__client_cnp_rau)
        eroarea = str(eroare.exception)
        self.assertEqual(
            eroarea,
            "CNP-ul trebuie sa aiba exact 12 numere!\nCNP-ul nu poate fi compus din litere!\n"
        )

        with self.assertRaises(ValidError) as eroare:
            validClienti.valideaza_client(self.__client_rau)
        eroarea = str(eroare.exception)
        self.assertEqual(
            eroarea,
            "Id invalid!\nNume invalid!\nCNP-ul trebuie sa aiba exact 12 numere!\nCNP-ul nu poate fi compus din litere!\n"
        )
        self.__validareClienti = validClienti
Esempio n. 2
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. 3
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. 4
0
    def __test_actualizare_Client(self):
        self.__repoClient = RepoClient()
        self.__client = client(23, "andrei", "123567345987")
        self.__repoClient.adauga(self.__client)
        self.__repoClient.actualizeaza(client(23, "andreicata",
                                              "122122122122"))
        cheie_client = self.__client.getId()
        client_gasit = self.__repoClient.cauta(cheie_client)
        self.assertEqual(client_gasit.getNume(), "andreicata")
        self.assertEqual(client_gasit.getCNP(), "122122122122")

        with self.assertRaises(RepoError) as eroare:
            self.__repoClient.actualizeaza(
                client(55, "catalin", "122134322122"))
        eroarea = str(eroare.exception)
        self.assertEqual(eroarea, "Id inexistent!\n")

        self.__serviceClienti = ServiceClienti(self.__repoClient,
                                               self.__validareClienti)
        with self.assertRaises(ValidError) as eroare:
            self.__serviceClienti.update_client(23, "", "122134322122111")
        eroarea = str(eroare.exception)
        self.assertEqual(
            eroarea,
            "Nume invalid!\nCNP-ul trebuie sa aiba exact 12 numere!\n")
Esempio n. 5
0
    def __test_adaugare_Client(self):
        self.__repoClient = RepoClient()
        self.assertEqual(self.__repoClient.size(), 0)
        self.__client = client(23, "andrei", "123567345987")
        self.__repoClient.adauga(self.__client)
        self.assertEqual(self.__repoClient.size(), 1)
        cheie_client = self.__client.getId()
        client_gasit = self.__repoClient.cauta(cheie_client)
        self.assertEqual(client_gasit.getNume(), self.__client.getNume())
        self.assertEqual(client_gasit.getCNP(), self.__client.getCNP())
        self.__alt_client_acelasi_id = client(23, None, None)

        with self.assertRaises(RepoError) as eroare:
            self.__repoClient.adauga(self.__alt_client_acelasi_id)
        eroarea = str(eroare.exception)
        self.assertEqual(eroarea, "Id existent!\n")

        self.__alt_client = client(12, "catalin", "123678397098")

        with self.assertRaises(RepoError) as eroare:
            self.__repoClient.cauta(self.__alt_client)
        eroarea = str(eroare.exception)
        self.assertEqual(eroarea, "Id inexistent!\n")

        clienti = self.__repoClient.get_all()
        self.assertEqual(clienti, [self.__client])
Esempio n. 6
0
    def __test_stergere_Client(self):
        self.__repoClient = RepoClient()
        self.__repoClient.adauga(client(19, "andrei", "123123123123"))
        self.__repoClient.adauga(client(20, "mihai", "109847345987"))
        self.__repoClient.adauga(client(21, "tudor", "123567410487"))
        self.__repoClient.adauga(client(22, "petricel", "123567000087"))
        self.assertEqual(self.__repoClient.size(), 4)
        self.__repoClient.stergere(22)
        self.assertEqual(self.__repoClient.size(), 3)

        with self.assertRaises(RepoError) as eroare:
            self.__repoClient.cauta(22)
        eroarea = str(eroare.exception)
        self.assertEqual(eroarea, "Id inexistent!\n")

        self.__repoClient.stergere(19)
        self.assertEqual(self.__repoClient.size(), 2)

        with self.assertRaises(RepoError) as eroare:
            self.__repoClient.cauta(19)
        eroarea = str(eroare.exception)
        self.assertEqual(eroarea, "Id inexistent!\n")

        with self.assertRaises(RepoError) as eroare:
            self.__repoClient.stergere(1)
        eroarea = str(eroare.exception)
        self.assertEqual(eroarea, "Id inexistent!\n")
Esempio n. 7
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. 8
0
    def __test_Client_cauta(self):
        self.__repoClient = RepoClient()
        self.__client_inexistent = client(24, "nicolas", "123464267345")

        with self.assertRaises(RepoError) as eroare:
            self.__repoClient.cauta(self.__client_inexistent)
        eroarea = str(eroare.exception)
        self.assertEqual(eroarea, "Id inexistent!\n")
Esempio n. 9
0
 def __test_creeaza_client(self):
     idClient = 19
     nume = "DanutIon"
     cnp = "124890349210"
     clientul = client(idClient, nume, cnp)
     self.assertEqual(clientul.getNume(), "DanutIon")
     self.assertEqual(clientul.getCNP(), "124890349210")
     self.assertTrue(clientul.getId() == 19)
     clientul.setNume("DanAndreas")
     self.assertEqual(clientul.getNume(), "DanAndreas")
     self.__client = clientul
Esempio n. 10
0
 def update_client(self, idClient, nume, cnp):
     clientul = client(idClient, nume, cnp)
     self.__validClient.valideaza_client(clientul)
     self.__repoClienti.actualizeaza(clientul)
Esempio n. 11
0
 def add_client(self, idClient, nume, cnp):
     clientul = client(idClient, nume, cnp)
     self.__validClient.valideaza_client(clientul)
     self.__repoClienti.adauga(clientul)