Exemplo n.º 1
0
 def __testRepo(self):
     assert len(self.__filmRepo)==0
     assert len(self.__clientRepo)==0
     self.__filmRepo.adauga(self.__film)
     assert len(self.__filmRepo)==1
     try:
         self.__filmRepo.adauga(self.__film)
     except ValueError as er:
         assert str(er)=='Element existent!'
     try:
         self.__filmRepo.cauta(self.__bfilm)
     except ValueError as er:
         assert str(er)=='Element inexistent!'
     keyFilm=Film(self.__idf,None,None,None)
     assert self.__filmRepo.cauta(keyFilm)==self.__film
     self.__filmRepo.adauga(self.__bfilm)
     assert self.__filmRepo.getAll()==[self.__film, self.__bfilm]
     newFilm=Film(self.__bidf,'AmericanPie','2013','comedie')
     self.__filmRepo.update(newFilm)
     assert self.__filmRepo.getAll()==[self.__film,newFilm]
     self.__filmRepo.sterge(self.__film)
     assert self.__filmRepo.getAll()==[newFilm]
     removeElem=Film(self.__bidf,None,None,None)
     self.__filmRepo.sterge(removeElem)
     try:
         self.__filmRepo.update(removeElem)
     except ValueError as er:
         assert str(er)=='Element inexistent!'
     assert self.__filmRepo.getAll()==[]
Exemplo n.º 2
0
 def stergeFilm(self, idf):
     '''
     Functia care sterge un element din lista cu filme
     Input: idf-id-ul filmului care trebuie sters
     '''
     f = Film(idf, None, None, None)
     self.__filmRepo.sterge(f)
Exemplo n.º 3
0
 def setUp(self):
     val=ValidatorFilm()
     clearFileContent('testunitf.txt')
     repo=FilmFileRepo('testunitf.txt')
     self.contr=ControllerFilm(repo, val)
     self.contr.adaugaFilm(20,'Titanic','1997','romantic')
     self.f=Film(20,'Titanic','1997','romantic')
Exemplo n.º 4
0
 def __init__(self):
     self.__idf=2
     self.__titlu='Titanic'
     self.__an='1997'
     self.__gen='romantic'
     self.__film=Film(self.__idf,self.__titlu,self.__an,self.__gen)
     self.__bidf=-23
     self.__btitlu=''
     self.__ban='2398'
     self.__bgen=''
     self.__bfilm=Film(self.__bidf,self.__btitlu,self.__ban,self.__bgen)
     self.__idc=5
     self.__nume='Mihai'
     self.__CNP='1990212113344'
     self.__client=Client(self.__idc,self.__nume,self.__CNP)
     self.__bidc=-5
     self.__bnume=''
     self.__bCNP='9995067113342'
     self.__bclient=Client(self.__bidc,self.__bnume,self.__bCNP)
     self.__validatorf=ValidatorFilm()
     self.__validatorc=ValidatorClient()
     #self.__filmRepo=FilmRepository()
     #self.__clientRepo=ClientRepository()
     #self.__contrFilm=ControllerFilm(self.__filmRepo,self.__validatorf)
     #self.__contrClient=ControllerClient(self.__clientRepo,self.__validatorc)
     self.__returnare='27/12/2020'
     self.__inchiriere=Inchiriere(self.__film,self.__client,self.__returnare)
     self.__breturnare='12/13/2015'
     self.__binchiriere=Inchiriere(self.__bfilm,self.__bclient,self.__breturnare)
     self.__validatorir=ValidatorInchiriere()
     #self.__inchiriereRepo=InchiriereRepository()
     #self.__contrInchiriere=ControllerInchiriere(self.__inchiriereRepo,self.__validatorir,self.__filmRepo,self.__clientRepo)
     self.__filename='test.txt'
     self.__filenamec='testClienti.txt'
     self.__filenamei='testInchirieri.txt'
     clearFileContent(self.__filename)
     clearFileContent(self.__filenamec)
     clearFileContent(self.__filenamei)
     self.__fileRepof=FilmFileRepo('test.txt')
     self.__fileRepoc=ClientFileRepo(self.__filenamec)
     self.__fileRepoi=InchiriereFileRepo(self.__filenamei)
     self.__filmRepo=FilmFileRepo('test.txt')
     self.__clientRepo=ClientFileRepo(self.__filenamec)
     self.__inchiriereRepo=InchiriereFileRepo(self.__filenamei)
     self.__contrFilm=ControllerFilm(self.__filmRepo,self.__validatorf)
     self.__contrClient=ControllerClient(self.__clientRepo,self.__validatorc)
     self.__contrInchiriere=ControllerInchiriere(self.__inchiriereRepo,self.__validatorir,self.__filmRepo,self.__clientRepo)
Exemplo n.º 5
0
 def stergeDupaFilm(self, idf):
     '''
     Sterge toate inchirierile care contin filmul cu id-ul dat
     '''
     f = Film(idf, None, None, None)
     listaInchirieri = self.__inchiriereRepo.cauta_film(f)
     for el in listaInchirieri:
         self.__inchiriereRepo.sterge(el)
Exemplo n.º 6
0
 def cautaFilm(self, idf):
     '''
     Functia care cauta un film in lista cu filme dupa id
     Input: idf
     Preconditii: idf-id-ul filmului care trebuie cautat
     Returneaza obiectul tip film cu id-ul cerut
     '''
     f = Film(idf, None, None, None)
     return self.__filmRepo.cauta(f)
Exemplo n.º 7
0
 def strInchiriere(self, idf, idc, returnare):
     '''
     Functia care returneaza un string care contine inchirierea
     '''
     f = Film(idf, None, None, None)
     c = Client(idc, None, None)
     film = self.__filmRepo.cauta(f)
     client = self.__clientRepo.cauta(c)
     return str(idf) + '-' + film.get_titlu() + ' ' + str(
         idc) + '-' + client.get_nume() + ' ' + returnare
Exemplo n.º 8
0
 def modificaDupaFilm(self, idf):
     '''
     Modifica toate inchirierile care au acelasi film
     '''
     f = Film(idf, None, None, None)
     film = self.__filmRepo.cauta(f)
     listaInchirieri = self.__inchiriereRepo.cauta_film(f)
     for el in listaInchirieri:
         i = Inchiriere(film, el.get_client(), el.get_returnare())
         self.__inchiriereRepo.update(i)
Exemplo n.º 9
0
 def setUp(self):
     clearFileContent('testFilm1.txt')
     clearFileContent('testClienti1.txt')
     clearFileContent('testInchirieri1.txt')
     repof = FilmFileRepo('testFilm1.txt')
     repoc = ClientFileRepo('testClienti1.txt')
     repoi = InchiriereFileRepo('testInchirieri1.txt')
     validator = ValidatorInchiriere()
     self.contr = ControllerInchiriere(repoi, validator, repof, repoc)
     self.f1 = Film(10, 'Titanic', '1997', 'romantic')
     self.f2 = Film(11, 'Divergent', '2017', 'actiune')
     self.c1 = Client(10, 'Diana', '2990806123456')
     self.c2 = Client(12, 'Valentin', '1921012123456')
     repof.adauga(self.f1)
     repof.adauga(self.f2)
     repoc.adauga(self.c1)
     repoc.adauga(self.c2)
     self.contr.adaugaInchiriere(10, 10, '12/12/2019')
     self.contr.adaugaInchiriere(11, 12, '13/01/2020')
     self.contr.adaugaInchiriere(10, 12, '13/12/2019')
Exemplo n.º 10
0
 def stergeInchiriere(self, idf, idc):
     '''
     Functia care sterge o inchiriere din lista de inchirieri
     Input: idf,idc
     Preconditii: idf-id-ul unui film deja adaugat in lista
                  idc-id-ul unui client deja adaugat in lista
     '''
     film = Film(idf, None, None, None)
     client = Client(idc, None, None)
     i = Inchiriere(film, client, None)
     self.__inchiriereRepo.sterge(i)
Exemplo n.º 11
0
 def modificaFilm(self, idf, titlu, an, gen):
     '''
     Functia care modifica un film in fucntie de id
     Input: idf,titlu,an,gen
     Preconditii: idf-id-ul filmului care trebuie inlocuit
                  titlu-titlul filmului nou
                  an-anul de aparitie al filmului nou
                  gen-genul filmului nou
     Functia valideaza obiectul
     '''
     f = Film(idf, titlu, an, gen)
     self.__validatorf.ValidareFilm(f)
     self.__filmRepo.update(f)
Exemplo n.º 12
0
 def adaugaFilm(self, idf, titlu, an, gen):
     '''
     Functia care adauga un element in lista de filme
     Input: idf,titlu,an,gen
     Preconditii: idf-id-ul filmului-
                  titlu-titlul filmului
                  an-anul de aparitie al filmului
                  gen-genul filmului
     Functia valideaza obiectul
     '''
     f = Film(idf, titlu, an, gen)
     self.__validatorf.ValidareFilm(f)
     self.__filmRepo.adauga(f)
Exemplo n.º 13
0
 def adaugaInchiriere(self, idf, idc, returnare):
     '''
     Functia care adauga o inchiriere in lista de inchirieri
     Input: idf,idc,returnare
     Preconditii: idf-id-ul unui film deja adaugat in lista
                  idc-id-ul unui client deja adaugat in lista
                  returnare-data returnarii filmului
     '''
     f = Film(idf, None, None, None)
     c = Client(idc, None, None)
     film = self.__filmRepo.cauta(f)
     client = self.__clientRepo.cauta(c)
     i = Inchiriere(film, client, returnare)
     self.__validatorinch.ValidareInchiriere(i)
     self.__inchiriereRepo.adauga(i)
Exemplo n.º 14
0
 def cautaInchiriere(self, idf, idc):
     '''
     Cauta in lista cu inchirieri inchirierea dupa id-ul filmului si cel al clientului
     Input: idf,idc
     Preconditii: idf-id-ul unui film deja adaugat in lista
                  idc-id-ul unui client deja adaugat in lista
     '''
     film = Film(idf, None, None, None)
     client = Client(idc, None, None)
     i = Inchiriere(film, client, None)
     i = self.__inchiriereRepo.cauta(i)
     film = self.__filmRepo.cauta(film)
     client = self.__clientRepo.cauta(client)
     i.set_client(client)
     i.set_film(film)
     return i
Exemplo n.º 15
0
 def prepare_movie_list(self):
     filmy = []
     f = open(self.path + 'film.csv')
     with f:
         csvreader = csv.reader(f, delimiter=';')
         next(csvreader, None)
         for record in csvreader:
             idFilmu = int(record[0])
             nazwa = record[1]
             dlugoscTrwania = int(record[2])
             data = record[3]
             dataDodania = int(data[6:10])
             cena = int(record[4])
             rezyser = None
             aktorzy = []
             oceny = []
             film = Film(idFilmu, nazwa, dataDodania, dlugoscTrwania, rezyser, aktorzy, oceny, cena)
             filmy.append(film)
     return filmy
Exemplo n.º 16
0
 def test_Modifica(self):
     self.contr.modificaFilm(20,'TitanicNew','2000','drama')
     self.assertTrue(self.contr.getAllF()==[Film(20,'TitanicNew','2000','drama')])
     self.assertRaises(ValueError,self.contr.modificaFilm,2,'TitanicNew','2000','drama')
Exemplo n.º 17
0
 def __testController(self):
     assert self.__contrFilm.getAllF()==[]
     self.__contrFilm.adaugaFilm(self.__idf,self.__titlu,self.__an,self.__gen)
     assert self.__contrFilm.getAllF()==[self.__film]
     newFilm=Film(7,'MazeRunner','2017','actiune')
     self.__contrFilm.adaugaFilm(7,'MazeRunner','2017','actiune')
     assert self.__contrFilm.getAllF()==[self.__film,newFilm]
     try:
         self.__contrFilm.adaugaFilm(self.__bidf,self.__btitlu,self.__ban,self.__bgen)
         assert False
     except ValueError as er:
         assert str(er)=='id negativ!\ntitlu invalid!\nan invalid!\ngen invalid!\n'
     assert self.__contrFilm.getAllF()==[self.__film,newFilm]
     assert self.__contrClient.getAllC()==[]
     self.__contrClient.adaugaClient(self.__idc,self.__nume,self.__CNP)
     assert self.__contrClient.getAllC()==[self.__client]
     newClient=Client(19,'Mihaela','2931229111335')
     self.__contrClient.adaugaClient(19,'Mihaela','2931229111335')
     assert self.__contrClient.getAllC()==[self.__client,newClient]
     try:
         self.__contrClient.adaugaClient(self.__bidc,self.__bnume,self.__bCNP)
     except ValueError as er:
         assert str(er)=='id negativ!\nnume invalid!\nCNP invalid!\n'
     assert self.__contrClient.getAllC()==[self.__client,newClient]
     self.__contrFilm.stergeFilm(self.__idf)
     assert self.__contrFilm.getAllF()==[newFilm]
     try:
         self.__contrFilm.stergeFilm(self.__idf)
     except ValueError as er:
         assert str(er)=='Element inexistent!'
     upFilm=Film(7,'MazeRunner3','2018','actiune')
     self.__contrFilm.modificaFilm(7,'MazeRunner3','2018','actiune')
     assert self.__contrFilm.getAllF()==[upFilm]
     assert self.__contrFilm.cautaFilm(7)==upFilm
     assert self.__contrClient.cautaClient(self.__idc)==self.__client
     try:
         self.__contrFilm.cautaFilm(self.__idf)
         assert False
     except ValueError as er:
         assert str(er)=='Element inexistent!'
         
     self.__contrFilm.adaugaFilm(self.__idf,self.__titlu,self.__an,self.__gen)
         
     assert self.__contrInchiriere.getAllI()==[]
   
     self.__contrInchiriere.adaugaInchiriere(self.__idf,self.__idc,self.__returnare)
     assert self.__contrInchiriere.getAllI()==[self.__inchiriere]
     try:
         self.__contrInchiriere.adaugaInchiriere(self.__bidf,self.__bidc,self.__breturnare)
         assert False
     except ValueError as er:
         assert str(er)=='Element inexistent!'
     try:
         self.__contrInchiriere.modificaInchiriere(self.__bidf,self.__idc,'12/10/2020')
         assert False
     except ValueError as er:
         assert str(er)=='Element inexistent!'
     self.__contrInchiriere.modificaInchiriere(self.__idf,self.__idc,'12/10/2020')
     newInchiriere=Inchiriere(self.__film,self.__client,'12/10/2020')
     assert self.__contrInchiriere.getAllI()==[newInchiriere]
     try:
         self.__contrInchiriere.stergeInchiriere(self.__bidf,self.__idc)
         assert False
     except ValueError as er:
         assert str(er)=='Element inexistent!' 
     assert self.__contrInchiriere.cautaInchiriere(self.__idf,self.__idc)==newInchiriere
     try:
         self.__contrInchiriere.cautaInchiriere(self.__idf,self.__bidc)
         assert False
     except ValueError as er:
         assert str(er)=='Element inexistent!' 
     self.__contrInchiriere.stergeInchiriere(self.__idf,self.__idc)
     assert self.__contrInchiriere.getAllI()==[]