def testGetToti(): repo_st = repo_student() st = student(12, 'Ion', 30) st1 = student(1, 'Ana', 88) repo_st.adauga_repo_student(st) repo_st.adauga_repo_student(st1) lista = repo_st.getToti() assert lista == [st, st1]
def test_adauga_repo_student(): repo_st = repo_student() st = student(12, 'Ion', 30) repo_st.adauga_repo_student(st) assert repo_st.getNumar() == 1 st2 = student(1, 'Ana', 88) repo_st.adauga_repo_student(st2) assert repo_st.getNumar() == 2
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_student(): repo_st = repo_student() st = student(12, 'Ion', 30) nume_nou = 'Ana' grup_nou = 88 repo_st.adauga_repo_student(st) repo_st.actualizeaza_repo_student(st.get_studentID(), nume_nou, grup_nou) assert st.get_nume() == nume_nou assert st.get_grup() == grup_nou
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 adauga_student(self,__studentID,__nume,__grup): ''' Functie ce adauga un student, il valideaza si adauga in repository :param __studentID:id-ul studentului-int :param __nume:numele studentului-string :param __grup:grupul studentului-int ''' st= student(__studentID,__nume,__grup) self.__validator.validate(st) self.__repo.adauga_repo_student(st) return st
def __loadFromFile(self): try: f = open(self.__fileName, "r") except IOError: return rez = [] for line in f.readlines(): if line != "": data = line.split(" ") studentID = data[0] nume = data[1] grup = data[2] st = student(studentID, nume, grup) rez.append(st) f.close() return rez
def genereaza_random(self, n): ''' Functie ce genereaza random un numar de n studenti :param n: numarul cerut de studenti-int ''' Alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' alphabet = 'abcdefghijklmnopqrstuvwxyz' for x in range(n): lungime = random.randint(2, 7) studentID = random.randint(1, 101) grup = random.randint(1, 101) nume = '' nume += random.choice(Alphabet) for i in range(lungime): nume += random.choice(alphabet) st = student(studentID, nume, grup) return st
def __loadFromFile(self): try: f = open(self.__fileName, "r") except IOError: return for line in f.readlines(): line.strip() if line != "": data = line.split(" ") studentID = data[0] nume = data[1] grup = data[2] st = student(studentID, nume, grup) repo_student.adauga_repo_student(self, st) f.close()
def test_repo(): fileName = "test.txt" repo = student_repo_file(fileName) assert repo.getNumar() == 0 repo.adauga_repo_student(student(5, "Andrei", 9)) assert repo.getNumar() == 1
def test_sterge_repo_student(): repo_st = repo_student() st = student(12, 'Ion', 30) repo_st.adauga_repo_student(st) repo_st.sterge_repo_student(st.get_studentID()) assert repo_st.getNumar() == 0