def modifica_student(self): student = Student(25, "laris") repo_stud = Repo() repo_stud.adauga(student) nume_change = "Andrei" cheie_stud = Student(24, None) try: repo_stud.cauta(cheie_stud) assert False except RepoError as re: assert str(re) == "item inexistent" cheie_stud = Student(25, None) stud_gasit = repo_stud.cauta(cheie_stud) repo_stud.modifica(stud_gasit, nume_change) assert repo_stud.cauta(stud_gasit).get_nume() == nume_change
def repo_delete_student(self): student = Student(25, "andrei") repo = Repo() repo.adauga(student) assert repo.size() == 1 cheie_student = Student(24, None) try: repo.delete(cheie_student) assert False except RepoError as re: assert str(re) == "item inexistent" cheie_student = Student(25, None) repo.delete(cheie_student) assert repo.size() == 0
def repo_delete_disciplina(self): disciplina = Disciplina(25, "andrei", "romana") repo = Repo() repo.adauga(disciplina) assert repo.size() == 1 cheie_disciplina = Disciplina(24, None, None) try: repo.delete(cheie_disciplina) assert False except RepoError as re: assert str(re) == "item inexistent" cheie_disciplina = Disciplina(25, None, None) repo.delete(cheie_disciplina) assert repo.size() == 0
def repo_adauga_student(self): student = Student(25, "laris") repo_stud = Repo() assert repo_stud.size() == 0 repo_stud.adauga(student) assert repo_stud.size() == 1 student = Student(25, "lala") try: repo_stud.adauga(student) assert False except RepoError as re: assert str(re) == "item deja existent!\n"
def test_adaug_nota(self): nota = Nota(1, 5, 7) repo = Repo() assert repo.size() == 0 repo.adauga(nota) assert repo.size() == 1 try: repo.adauga(nota) assert False except RepoError as re: assert str(re) == "item deja existent!\n"
def repo_adauga_disciplina(self): disciplina = Disciplina(1, "mate", "berinde") repo = Repo() assert repo.size() == 0 repo.adauga(disciplina) try: repo.adauga(disciplina) assert False except RepoError as re: assert str(re) == "item deja existent!\n"
def caut_stud(self): student = Student(1, "Andrei") repo = Repo() repo.adauga(student) cheie = Student(2, None) try: repo.cauta(cheie) assert False except RepoError as re: assert str(re) == "item inexistent" cheie = Student(1, None) gasit = repo.cauta(cheie) assert gasit.get_id() == 1 assert gasit.get_nume() == "Andrei"
def caut_disciplina(self): disciplina = Disciplina(25, "andrei", "romana") repo = Repo() repo.adauga(disciplina) cheie = Disciplina(23, "andrei", "romana") try: repo.cauta(cheie) assert False except RepoError as re: assert str(re) == "item inexistent" cheie = Disciplina(25, "andrei", "romana") gasit = repo.cauta(cheie) assert gasit.get_id() == 25 assert gasit.get_nume() == "romana" assert gasit.get_materie() == "andrei"
from testing.teste import Teste from infrastructura.repo import Repo from validatoare.validare import ValidatorStudent, ValidatorDisciplina, ValidatorNote from business.services import ServiceStudent, ServiceDisciplina, ServiceNote from presentation.controller import Console teste = Teste() teste.run() validStudent = ValidatorStudent() validDisciplina = ValidatorDisciplina() validNote = ValidatorNote() repoStudent = Repo() repoDisciplina = Repo() repoNote = Repo() srvStudent = ServiceStudent(repoStudent, validStudent) srvDisciplina = ServiceDisciplina(repoDisciplina, validDisciplina) srvNote = ServiceNote(repoNote, validNote) ui = Console(srvStudent, srvDisciplina, srvNote) ui.run()
def test_validare_nota(self): nota_negativa = Nota(1, -3, 2) nota_prea_mare = Nota(1, 12, 2) nota_student_inexistent = Nota(5, 7, 2) nota_disc_inexistenta = Nota(1, 7, 3) nota = Nota(1, 3, 2) stud = Student(1, "Japonia") repo_stud = Repo() repo_stud.adauga(stud) disc = Disciplina(2, "mate", "info") repo_disc = Repo() repo_disc.adauga(disc) valid = ValidatorNote() valid.valideaza_note( nota, repo_stud.exista(Student(nota.get_student(), None)), repo_disc.exista(Disciplina(nota.get_id_disciplina(), None, None))) try: valid.valideaza_note( nota_negativa, repo_stud.exista(Student(nota_negativa.get_student(), None)), repo_disc.exista( Disciplina(nota_negativa.get_id_disciplina(), None, None))) assert False except ValidError as ve: assert str(ve) == "nota nu poate fi negativa\n" try: valid.valideaza_note( nota_prea_mare, repo_stud.exista(Student(nota_prea_mare.get_student(), None)), repo_disc.exista( Disciplina(nota_prea_mare.get_id_disciplina(), None, None))) assert False except ValidError as ve: assert str(ve) == "nota nu poate fi mai mare decat 10\n" try: valid.valideaza_note( nota_student_inexistent, repo_stud.exista( Student(nota_student_inexistent.get_student(), None)), repo_disc.exista( Disciplina(nota_student_inexistent.get_id_disciplina(), None, None))) assert False except ValidError as ve: assert str( ve) == "nota nu poate fi data la un student inexistent\n" try: valid.valideaza_note( nota_disc_inexistenta, repo_stud.exista( Student(nota_disc_inexistenta.get_student(), None)), repo_disc.exista( Disciplina(nota_disc_inexistenta.get_id_disciplina(), None, None))) assert False except ValidError as ve: assert str( ve) == "nota nu poate fi data la o materie inexistenta\n"
def modifica_disciplina(self): disciplina = Disciplina(25, "mate", "ladla") repo = Repo() repo.adauga(disciplina) nume_change = "Andrei" materie_change = "info" cheie_disciplina = Disciplina(24, None, None) try: repo.cauta(cheie_disciplina) assert False except RepoError as re: assert str(re) == "item inexistent" cheie_disciplina = Disciplina(25, None, None) disciplina_gasita = repo.cauta(cheie_disciplina) repo.modifica(disciplina_gasita, nume_change) repo.modifica_materie(disciplina_gasita, materie_change) assert repo.cauta(disciplina_gasita).get_nume() == nume_change assert repo.cauta(disciplina_gasita).get_materie() == materie_change