Пример #1
0
def testFilmeRepo():
    fName = "test.txt"
    clearFileContent(fName)
    repo = FilmeFileRepo(fName)
    assert len(repo.getAll()) == 0
    repo.store(Film(1, "Sabrina", "Horror", "SF"))
    assert len(repo.getAll()) == 1
    repo.store(Film(2, "West World", "Interzis", "Drama"))
    assert repo.find("Sabrina") == Film(1, "Sabrina", "Horror", "SF")
    assert len(repo.getAll()) == 2
    repo.sterge("Sabrina")
    assert len(repo.getAll()) == 1
    repo.modifica("West World", "Friend", "About friends", "Comedy")
    assert repo.find("Friend") == Film(2, "Friend", "About friends", "Comedy")
Пример #2
0
def testStoreFilm():
    film1 = Film(1, "Sabrina", "Interzis sub 16 ani", "Horror,SF")
    rep = FilmeRepo()
    rep.store(film1)
    assert len(rep.getAll()) == 1
    film2 = Film(2, "West World", "Interzis sub 18 ani", "Drama")
    rep.store(film2)
    assert len(rep.getAll()) == 2
    film3 = rep.find("Sabrina")
    assert film3 == film1
    rep.sterge("Sabrina")
    assert len(rep.getAll()) == 1
    film4 = rep.modifica("West World", "Elena", "aywdga", "wauegy")
    film5 = Film(3, "Elena", "aywdga", "wauegy")
    assert film4 == film5
Пример #3
0
 def store(self, Film):
     """
     Stocheaza filmele.
     """
     if Film in self.__filmeStore.values():
         raise ValueError("Film exista deja.")
     self.__filmeStore[Film.getId()] = Film
Пример #4
0
def testFilmValidator():
    validator = Validator()
    fl = Film(1, "", "", "")
    try:
        validator.validateFilm(fl)
        assert False
    except ValidatorException as ex:
        assert len(ex.errors) == 3
Пример #5
0
 def createFilmFromLine(self, line):
     """
     Proceseaza o linie din fisier si creaza un film
     Returneaza un film
     """
     fields = line.split(";")
     fl = Film(fields[0], fields[1], fields[2], fields[3])
     return fl
Пример #6
0
 def find(self, titlu):
     """
     Cauta filmul dupa titlu
     """
     ok = False
     if self.__filmeStore != {}:
         for Film in self.__filmeStore.values():
             if Film.getTitlu() == titlu:
                 ok = True
                 return Film
     if ok == False:
         print("Filmul nu exista in lista.")
Пример #7
0
def testServiceFilme():
    repFilm = FilmeRepo()
    val = Validator()
    srv = ServiceFilme(repFilm, val)
    srv.createFilm(1, "Sabrina", "Interzis sub 16 ani", "Horror,SF")
    fl2 = srv.createFilm(2, "West World", "Interzis sub 18 ani", "Drama,SF")
    srv.createFilm(3, "Friends", "About Friends", "Comedie")
    assert len(srv.getAllFilm()) == 3
    assert srv.findTitlu("West World") == fl2
    fl3 = srv.stergeTitlu("West World")
    assert fl2 == fl3
    assert len(srv.getAllFilm()) == 2
    fl4 = srv.modificaFilm("Friends", "Doctors", "jieuh", "Comedie")
    fl5 = Film(4, "Doctors", "jieuh", "Comedie")
    assert fl4 == fl5
Пример #8
0
 def createFilm(self, id, titlu, descriere, gen):
     """
     Stocheaza filmul
     nume, prenume , CNP - siruri de caractere
     returneaza clientul
     raise RepositoryExeption - daca clientul exista deja
     raise ValidationException - daca datele date sunt invalide
     """
     #creaza obiectul student
     fl = Film(id, titlu, descriere, gen)
     #valideaza datele introduse de utilizator
     self.__val.validateFilm(fl)
     self.__val.validateRepoFilm(fl, self.getAllFilm())
     #stocheaza student folosind repository
     self.__repFilm.store(fl)
     return fl
Пример #9
0
def testStoreInchirieri():
    repFilm = FilmeRepo()
    repClient = ClientiRepo()
    film = Film(1, "Sabrina", "Interzis sub 16 ani", "Horror,SF")
    client = Client(1, "Titulescu", "Miguel", "2990901920390")
    repFilm.store(film)
    film.setId(1)
    client.setId(2)
    rep = InchirieriRepo()
    inchiriere = Inchirieri(film.getId(), client.getId(), film.getTitlu(),
                            client.getNume(), client.getPrenume(), False)
    rep.store(inchiriere)
    assert len(rep.getAll()) == 1
    rep.returnareFilm("Titulescu", "Miguel", "Sabrina")
    assert inchiriere.getAdus() == True
    inchiriere1 = Inchirieri(2, 3, "Sabrina", "Asmarandei", "Ana-Maria", False)
    rep.store(inchiriere1)
    inchiriere2 = Inchirieri(3, 3, "Friends", "Asmarandei", "Ana-Maria", False)
    rep.store(inchiriere2)