def TestLen(self):
     '''
     Testeaza functia de lungime a listei de elemente 
     '''
     repo = RepositoryNota()
     assert len(repo) == 0
     repo.add(1)
     assert len(repo) == 1
 def TestRemove(self):
     '''
     Testeaza functia de adaugare a unui element
     '''
     repo = RepositoryNota()
     repo.add(1)
     repo.add(2)
     repo.removeEl(1)
     assert repo.getAll() == [2]
     repo.removeEl(2)
     assert repo.getAll() == []
 def TestGetNoteDisciplinaStudent (self):
     '''
     Testeaza functia de obtinere a tuturor notelor pentru un student la o anumita disciplina
     '''
     repo = RepositoryNota ()
     NoteServ = NotaService (repo)
     nota1 = Nota (1,2,9)
     nota2 = Nota (1,5,10)
     nota3 = Nota (1,2,7)
     nota4 = Nota (1,5,7)
     nota5 = Nota (1,2,8)
     nota6 = Nota (2,2,9)
     nota7 = Nota (2,2,8)
     NoteServ.AdaugaNota(nota1)
     NoteServ.AdaugaNota(nota2)
     NoteServ.AdaugaNota(nota3)
     NoteServ.AdaugaNota(nota4)
     NoteServ.AdaugaNota(nota5)
     NoteServ.AdaugaNota(nota6)
     NoteServ.AdaugaNota(nota7)
     assert NoteServ.GetNoteStudentDisciplina(2, 1) == [nota1, nota3, nota5]
     assert NoteServ.GetNoteStudentDisciplina(5,1) == [nota2, nota4]
     assert NoteServ.GetNoteStudentDisciplina(2, 2) == [nota6, nota7]
     assert NoteServ.GetNoteStudentDisciplina(5,5) == []
     assert NoteServ.GetNoteStudentDisciplina(10, 1) == []
     assert NoteServ.GetNoteStudentDisciplina(17, 20) == []
 def TestGetTopMedii (self):
     '''
     Testeaza functia de obtinere a mediilor in ordine descrescatoare
     '''
     repo = RepositoryNota ()
     NoteServ = NotaService (repo)
     StudServ = StudentService(Repository())
     StudServ.adaugaStudent(Student(1,'asd'))
     StudServ.adaugaStudent(Student(2,'asd'))
     nota1 = Nota (1,2,9)
     nota2 = Nota (1,5,10)
     nota3 = Nota (1,2,7)
     nota4 = Nota (1,5,7)
     nota5 = Nota (1,2,8)
     nota6 = Nota (2,2,9)
     nota7 = Nota (2,2,8)
     NoteServ.AdaugaNota(nota1)
     NoteServ.AdaugaNota(nota2)
     NoteServ.AdaugaNota(nota3)
     NoteServ.AdaugaNota(nota4)
     NoteServ.AdaugaNota(nota5)
     NoteServ.AdaugaNota(nota6)
     NoteServ.AdaugaNota(nota7)
     listNote = NoteServ.GetNote()
     listStud = StudServ.getStudenti()
     assert NoteServ.GetTopMedii(listNote, listStud) == [8.5, 8.2]
 def TestAdaugaNota(self):
     '''
     Testeaza functia de initializare a NotaService
     '''
     repo = RepositoryNota ()
     NoteServ = NotaService(repo)
     nota1 = Nota (1,4,7)
     NoteServ.AdaugaNota(nota1)
     assert NoteServ.GetNote() == [nota1]
     nota2 = Nota (2,4,9)
     NoteServ.AdaugaNota(nota2)
     assert NoteServ.GetNote() == [nota1, nota2]
 def TestGetMedieStudent (self):
     '''
     Testeaza functia de obtinere a mediei unui student 
     '''
     repo = RepositoryNota ()
     NoteServ = NotaService (repo)
     nota1 = Nota (1,2,9)
     nota2 = Nota (1,5,10)
     nota3 = Nota (1,2,7)
     nota4 = Nota (1,5,7)
     nota5 = Nota (1,2,8)
     nota6 = Nota (2,2,9)
     nota7 = Nota (2,2,8)
     NoteServ.AdaugaNota(nota1)
     NoteServ.AdaugaNota(nota2)
     NoteServ.AdaugaNota(nota3)
     NoteServ.AdaugaNota(nota4)
     NoteServ.AdaugaNota(nota5)
     NoteServ.AdaugaNota(nota6)
     NoteServ.AdaugaNota(nota7)
     assert NoteServ.GetMedieStudent(Student(1,'asd')) == 8.2
     assert NoteServ.GetMedieStudent(Student(2,'asd')) == 8.5
 def TestGetNoteStudent (self):
     '''
     Testeaza functia de obtiere a tuturor notelor unui student 
     '''
     repo = RepositoryNota ()
     nota1 = Nota (1,2,9)
     nota2 = Nota (1,5,10)
     nota3 = Nota (1,2,7)
     nota4 = Nota (1,5,7)
     nota5 = Nota (1,2,8)
     nota6 = Nota (2,2,9)
     nota7 = Nota (2,2,8)
     NoteServ = NotaService (repo)
     NoteServ.AdaugaNota(nota1)
     NoteServ.AdaugaNota(nota2)
     NoteServ.AdaugaNota(nota3)
     NoteServ.AdaugaNota(nota4)
     NoteServ.AdaugaNota(nota5)
     NoteServ.AdaugaNota(nota6)
     NoteServ.AdaugaNota(nota7)
     assert NoteServ.GetNoteStudent(Student(1,'Paul')) == [nota1, nota2, nota3, nota4, nota5]
     assert NoteServ.GetNoteStudent(Student(2,'Adi')) == [nota6, nota7]
 def TestGetMedieStudentDisciplina (self):
     '''
     Testeaza functia de obtinere a mediei unui student la o anumita disciplina 
     '''
     repo = RepositoryNota ()
     NoteServ = NotaService (repo)
     nota1 = Nota (1,2,9)
     nota2 = Nota (1,5,10)
     nota3 = Nota (1,2,7)
     nota4 = Nota (1,5,7)
     nota5 = Nota (1,2,8)
     nota6 = Nota (2,2,9)
     nota7 = Nota (2,2,8)
     NoteServ.AdaugaNota(nota1)
     NoteServ.AdaugaNota(nota2)
     NoteServ.AdaugaNota(nota3)
     NoteServ.AdaugaNota(nota4)
     NoteServ.AdaugaNota(nota5)
     NoteServ.AdaugaNota(nota6)
     NoteServ.AdaugaNota(nota7)
     assert NoteServ.GetMedieStudentDisc(1, 2) == 8
     assert NoteServ.GetMedieStudentDisc(1,5) == 8.5
     assert NoteServ.GetMedieStudentDisc(2,2) == 8.5
 def TestRemoveNoteDisciplina(self):
     '''
     Testeaza functia de stergere a tuturor notelor de la o anumita disciplina
     '''
     repo = RepositoryNota ()
     NoteServ = NotaService (repo)
     nota1 = Nota (1,2,9)
     nota2 = Nota (1,5,10)
     nota3 = Nota (1,2,7)
     nota4 = Nota (1,5,7)
     nota5 = Nota (1,2,8)
     nota6 = Nota (2,2,9)
     nota7 = Nota (2,2,8)
     NoteServ.AdaugaNota(nota1)
     NoteServ.AdaugaNota(nota2)
     NoteServ.AdaugaNota(nota3)
     NoteServ.AdaugaNota(nota4)
     NoteServ.AdaugaNota(nota5)
     NoteServ.AdaugaNota(nota6)
     NoteServ.AdaugaNota(nota7)
     NoteServ.RemoveNoteDisciplina(2)
     assert NoteServ.GetNote() == [nota2, nota4]
     NoteServ.RemoveNoteDisciplina(5)
     assert NoteServ.GetNote() == []
 def TestRemoveNoteStudent(self):
     '''
     Testeaza functia de stergere a tuturor notelor unui student
     '''
     repo = RepositoryNota ()
     NoteServ = NotaService (repo)
     nota1 = Nota (1,2,9)
     nota2 = Nota (1,5,10)
     nota3 = Nota (1,2,7)
     nota4 = Nota (1,5,7)
     nota5 = Nota (1,2,8)
     nota6 = Nota (2,2,9)
     nota7 = Nota (2,2,8)
     NoteServ.AdaugaNota(nota1)
     NoteServ.AdaugaNota(nota2)
     NoteServ.AdaugaNota(nota3)
     NoteServ.AdaugaNota(nota4)
     NoteServ.AdaugaNota(nota5)
     NoteServ.AdaugaNota(nota6)
     NoteServ.AdaugaNota(nota7)
     NoteServ.RemoveNoteStudent(1)
     assert NoteServ.GetNote() == [nota6, nota7]
     NoteServ.RemoveNoteStudent(2)
     assert NoteServ.GetNote() == []
 def TestAdd(self):
     '''
     Testeaza functia de adaugare a unui element 
     '''
     repo = RepositoryNota()
     repo.add(1)
     assert repo.getAll() == [1]
     repo.add(2)
     assert repo.getAll() == [1, 2]
     repo.add(1)
     assert repo.getAll() == [1, 2, 1]
 def TestInit(self):
     '''
     Testeaza functia de initializare 
     '''
     repo = RepositoryNota()
     assert repo.getAll() == []
Ejemplo n.º 13
0
from Tests.Teste import Teste
from Repository.Repository import Repository
from Service.Student_Service import StudentService
from Service.Disciplina_Service import DisciplinaService
from UI.UI_Meniu import MenuConsole
from Repository.Repository_Nota import RepositoryNota
from Service.Nota_Service import NotaService

teste = Teste()
teste.runTeste()
Repo1 = Repository()
Repo2 = Repository()
Repo3 = RepositoryNota()
ComenziStud = StudentService(Repo1)
ComenziDisc = DisciplinaService(Repo2)
ComenziNota = NotaService(Repo3)
Console = MenuConsole(ComenziStud, ComenziDisc, ComenziNota)
Console.run()