def test_adauga_repo_problema(): repo_pr = repo_problema() pr = problema("12_2", "descriere", "02.08.2018") repo_pr.adauga_repo_problema(pr) assert repo_pr.getNumar() == 1 pr1 = problema("12_3", "descriere", "02.08.2018") repo_pr.adauga_repo_problema(pr1) assert repo_pr.getNumar() == 2
def testGetToti(): repo_pr = repo_problema() pr = problema("12_2", "descriere", "02.08.2018") pr1 = problema("12_9", "descriere", "09.09.2018") repo_pr.adauga_repo_problema(pr) repo_pr.adauga_repo_problema(pr1) lista = repo_pr.getToti() assert lista == [pr, pr1]
def testGetToti(): repo_not = repo_notare() st = student(12, 'Ion', 30) pr = problema("12_2", "descriere", "02.08.2018") nota1 = notare(st, pr, 8) repo_not.adauga_repo_nota(nota1) st = student(2, 'Andrei', 29) pr = problema("2_2", "descriere", "12.10.2018") nota2 = notare(st, pr, 6) repo_not.adauga_repo_nota(nota2) lista = repo_not.getToti() assert lista == [nota1, nota2]
def test_adauga_repo_notare(): repo_not = repo_notare() st = student(12, 'Ion', 30) pr = problema("12_2", "descriere", "02.08.2018") nota = notare(st, pr, 8) repo_not.adauga_repo_nota(nota) assert repo_not.getNumar() == 1
def test_actualizeaza_repo_notare(): repo_not = repo_notare() st = student(12, 'Ion', 30) pr = problema("12_2", "descriere", "02.08.2018") nota = notare(st, pr, 8) repo_not.adauga_repo_nota(nota) notaNoua = 9 repo_not.actualizeaza_repo_nota(nota.get_id(), notaNoua) assert nota.get_nota() == 9
def test_sterge_repo_notare(): repo_not = repo_notare() st = student(12, 'Ion', 30) pr = problema("12_2", "descriere", "02.08.2018") nota = notare(st, pr, 8) repo_not.adauga_repo_nota(nota) id = str(st.get_studentID()) + " " + str(pr.get_nrLab_nrPr()) repo_not.sterge_repo_nota(nota.get_id()) assert repo_not.getNumar() == 0
def test_actualizeaza_repo_problema(): repo_pr = repo_problema() pr = problema("12_2", "descriere", "02.08.2018") desc_noua = "descriereNoua" deadline_nou = "09.09.2018" repo_pr.adauga_repo_problema(pr) repo_pr.actualizeaza_repo_problema(pr.get_nrLab_nrPr(), desc_noua, deadline_nou) assert pr.get_descriere() == desc_noua assert pr.get_deadline() == deadline_nou
def adauga_problema(self, __nrLab_nrPr, __descriere, __deadline): ''' Functie ce adauga o problema, o valideaza si adauga in repository :param __nrLab_nrPr: numarul laboratorului si numarul problemei-string :param __descriere: descrierea problemei -string :param __deadline: deadline-ul problemei- string ''' pr = problema(__nrLab_nrPr, __descriere, __deadline) self.__validator.validate(pr) self.__repo.adauga_repo_problema(pr) return pr
def __loadFromFile(self): try: f = open(self.__fileName, 'r') except IOError: return for line in f.readlines(): if line != "": line = line.strip() data = line.split(" ") nrPr_nrLab = data[0] descriere = data[1] deadline = data[2] pr = problema(nrPr_nrLab, descriere, deadline) repo_problema.adauga_repo_problema(self, pr) f.close()
def test_sterge_repo_problema(): repo_pr = repo_problema() pr = problema("12_2", "descriere", "02.08.2018") repo_pr.adauga_repo_problema(pr) repo_pr.sterge_repo_problema(pr.get_nrLab_nrPr()) assert repo_pr.getNumar() == 0