def __ruleaza_teste_serviciu_statistici_media_lab_dat(self):
     repo_asign = RepositoryAsignare()
     repo_stud = RepositoryStudenti()
     repo_prob = RepositoryProbleme()
     valid = Validare_Asignare()
     srv = ServiceStatistici(repo_asign, repo_stud, repo_prob)
     student_1 = Student(5, "Alina", "411")
     repo_stud.adauga(student_1)
     student_2 = Student(7, "Daniel", "321")
     repo_stud.adauga(student_2)
     student_3 = Student(10, "Bogdan", "222")
     repo_stud.adauga(student_3)
     pb_1 = Problema("13_13", "grea", 16)
     pb_2 = Problema("13_14", "grea", 16)
     repo_prob.adauga(pb_1)
     repo_prob.adauga(pb_2)
     asign_1 = Asignare(88, 5, "13_13", 7)
     repo_asign.adauga(asign_1)
     asign_2 = Asignare(89, 7, "13_13", 7)
     repo_asign.adauga(asign_2)
     asign_3 = Asignare(90, 10, "13_13", 10)
     repo_asign.adauga(asign_3)
     answer = srv.raport_media_lab_dat("13_13")
     assert answer[0] == 3
     answer = srv.raport_media_lab_dat("15_15")
     assert answer[0] == 0
 def __ruleaza_teste_serviciu_statistici_ordonat_dupa_nota(self):
     repo_asign = RepositoryAsignare()
     repo_stud = RepositoryStudenti()
     repo_prob = RepositoryProbleme()
     valid = Validare_Asignare()
     srv = ServiceStatistici(repo_asign, repo_stud, repo_prob)
     student_1 = Student(5, "Alina", "411")
     repo_stud.adauga(student_1)
     student_2 = Student(7, "Daniel", "321")
     repo_stud.adauga(student_2)
     student_3 = Student(10, "Bogdan", "222")
     repo_stud.adauga(student_3)
     pb_1 = Problema("13_13", "grea", 16)
     repo_prob.adauga(pb_1)
     asign_1 = Asignare(88, 5, "13_13", 7)
     repo_asign.adauga(asign_1)
     asign_2 = Asignare(89, 7, "13_13", 9)
     repo_asign.adauga(asign_2)
     asign_3 = Asignare(90, 10, "13_13", 10)
     repo_asign.adauga(asign_3)
     lista = srv.raport_ordonat_dupa_nota("13_13")
     assert lista[0][0].get_nume() == "Alina"
     assert lista[2][0].get_nume() == "Bogdan"
     assert lista[1][1] == 9
     lista = srv.raport_ordonat_alfabetic("15_15")
     assert lista == []
Beispiel #3
0
    def __ruleaza_teste_repo(self):
        # adauga
        repo = RepositoryStudenti()
        assert repo.size() == 0
        studID = 2
        nume = "Alina"
        grup = 13
        student = Student(studID, nume, grup)
        repo.adauga(student)
        assert repo.size() == 1

        # get all
        all_stud = repo.get_all()
        assert len(all_stud) == 1

        # cautare
        key_persoana = Student(studID, None, None)
        gasit = repo.cauta(key_persoana)
        try:
            repo.adauga(key_persoana)
            assert False
        except RepoError as re:
            assert str(re) == "Element existent!\n"
        assert gasit.get_nume() == nume
        key_persoana_nu = Student(24, None, None)
        try:
            repo.cauta(key_persoana_nu)
            assert False
        except RepoError as re:
            assert str(re) == "Element inexistent!\n"

        # modificare
        student_nou = Student(2, "Mihai", "241")
        repo.modifica(student_nou)
        gasit = repo.cauta(key_persoana)
        assert gasit.get_grup() == "241"
        try:
            repo.modifica(key_persoana_nu)
            assert False
        except RepoError as re:
            assert str(re) == "Element inexistent!\n"

            # stergere si size
            repo.sterge(key_persoana)
            assert repo.size() == 0
            try:
                repo.sterge(key_persoana)
                assert False
            except RepoError as re:
                assert str(re) == "Element inexistent!\n"
Beispiel #4
0
 def sterge_stud(self, studID):
     """
     sterge un student dupa ID
     :param: studID - numar natural ( identificator unic al unei persoane)
     """
     key_persoana = Student(studID, None, None)
     self.__repo.sterge(key_persoana)
 def generate(self):
     """
     Genereaza automat nr studenti si ii adauga in repository
     :param: nr - numar natural
     :exception: Exception - in caul in care persoana generata este invalida
     """
     nr = 20
     while nr > 0:
         asign_ID = random.randrange(1, 100)
         stud_ID = random.randrange(1, 100)
         nrLab = random.randrange(1, 100)
         nrPb = random.randrange(1, 100)
         nrLab_nrPb = str(nrLab) + "_" + str(nrPb)
         nota = random.randrange(1, 10)
         asign = Asignare(asign_ID, stud_ID, nrLab_nrPb, nota)
         try:
             self.__valid.valideaza(asign)
             key_persoana = Student(stud_ID, None, None)
             self.__repo_stud.cauta(key_persoana)
             key_prob = Problema(nrLab_nrPb, None, None)
             self.__repo_prob.cauta(key_prob)
             self.__repo_asign.adauga(asign)
             nr = nr - 1
         except Exception:
             pass
Beispiel #6
0
 def gaseste_stud_by_ID(self, studID):
     """
     Gaseste un student dupa ID
     :param: studID - numar natural ( identificator unic al unui student)
     :return: Student (obiectul student cu ID-ul cautat)
     """
     key_student = Student(studID, None, None)
     return self.__repo.cauta(key_student)
Beispiel #7
0
 def modifica_stud(self, studID, nume, grup):
     """
     modifica numele si adresa unui student existent (dupa ID)
     :param: studID - numar natural ( identificator unic al unui student)
     :param: nume - string
     :param: grup - string
     """
     student_nou = Student(studID, nume, grup)
     self.__valid.valideaza(student_nou)
     self.__repo.modifica(student_nou)
Beispiel #8
0
 def adauga_student(self, studID, nume, grup):
     """
     adauga un student
     :param: studID - nr natural pozitiv ( identificator unic al unui student)
     :param: nume - string
     :param: grup - int
     """
     student = Student(studID, nume, grup)
     self.__valid.valideaza(student)
     self.__repo.adauga(student)
 def __ruleaza_teste_serviciu_media_5(self):
     repo_asign = RepositoryAsignare()
     repo_stud = RepositoryStudenti()
     repo_prob = RepositoryProbleme()
     valid = Validare_Asignare()
     srv = ServiceStatistici(repo_asign, repo_stud, repo_prob)
     student_1 = Student(6, "Mishu", "321")
     repo_stud.adauga(student_1)
     student_2 = Student(7, "Matei", "322")
     repo_stud.adauga(student_2)
     student_3 = Student(8, "Mircea", "352")
     repo_stud.adauga(student_3)
     problema_1 = Problema("14_1", "nasoala", 16)
     repo_prob.adauga(problema_1)
     problema_2 = Problema("13_1", "nasoala", 16)
     repo_prob.adauga(problema_2)
     problema_3 = Problema("12_1", "nasoala", 16)
     repo_prob.adauga(problema_3)
     problema_4 = Problema("11_1", "nasoala", 16)
     repo_prob.adauga(problema_4)
     problema_5 = Problema("10_1", "nasoala", 16)
     repo_prob.adauga(problema_5)
     problema_6 = Problema("9_1", "nasoala", 16)
     repo_prob.adauga(problema_6)
     asignare_1 = Asignare(21, 6, "14_1", 3)
     repo_asign.adauga(asignare_1)
     asignare_2 = Asignare(22, 7, "12_1", 5)
     repo_asign.adauga(asignare_2)
     asignare_3 = Asignare(23, 8, "14_1", 4)
     repo_asign.adauga(asignare_3)
     asignare_4 = Asignare(24, 6, "10_1", 3)
     repo_asign.adauga(asignare_4)
     asignare_5 = Asignare(25, 7, "14_1", 5)
     repo_asign.adauga(asignare_5)
     asignare_6 = Asignare(26, 8, "9_1", 4)
     repo_asign.adauga(asignare_6)
     lista_1 = srv.raport_media_5()
     assert len(lista_1) == 2
     assert lista_1[0][0].get_stud_id() == 6
     assert lista_1[0][0].get_nume() == "Mishu"
     assert lista_1[1][0].get_stud_id() == 8
Beispiel #10
0
 def __ruleaza_teste_validare(self):
     studID = -2
     nume = ""
     grup = 223
     student = Student(studID, nume, grup)
     valid = Validare_Student()
     try:
         valid.valideaza(student)
         assert False
     except ValidError as ve:
         assert str(
             ve
         ) == "ID-ul nu poate fi un numar negativ!\nNumele nu poate fi gol!\n"
Beispiel #11
0
 def __ruleaza_teste_serviciu_modificare(self):
     repo = RepositoryStudenti()
     valid = Validare_Student()
     srv = ServiceStudenti(repo, valid)
     studID = 2
     nume = "Alina"
     grup = "313"
     student = Student(studID, nume, grup)
     repo.adauga(student)
     assert repo.size() == 1
     nume_nou = "Catalina"
     grup_nou = "314"
     srv.modifica_stud(studID, nume_nou, grup_nou)
     key_persoana = Student(studID, None, None)
     gasit = repo.cauta(key_persoana)
     assert gasit.get_nume() == "Catalina"
     assert gasit.get_grup() == "314"
     try:
         srv.modifica_stud(3, nume_nou, grup_nou)
         assert False
     except RepoError as re:
         assert str(re) == "Element inexistent!\n"
 def adauga_asignare(self, asign_ID, stud_ID, nrLab_nrPb, nota):
     """
     adauga o asignare
     :param asign_ID: numar natural (identificatorul unic al unei asignari)
     :param stud_ID: numar natural (identificatorul unic al unui student)
     :param nrLab_nrPb: string (identificatorul unic al unei probleme)
     :param nota: numar natural(>0 si <10)
     """
     asign = Asignare(asign_ID, stud_ID, nrLab_nrPb, nota)
     self.__valid.valideaza(asign)
     key_student = Student(stud_ID, None, None)
     self.__repo_stud.cauta(key_student)
     key_prob = Problema(nrLab_nrPb, None, None)
     self.__repo_prob.cauta(key_prob)
     self.__repo_asign.adauga(asign)
 def raport_ordonat_dupa_nota(self, nrLab_nrPb):
     """
     Returneaza o lista de studenți și notele lor la o problema de laborator dat, ordonat dupa nota
     :param: nrLab_nrPb - string (identificatorul unic al unei pb)
     :return: lista - list(lista de studenti si notele lor la o pb de laborator dat, in ordine dupa nume)
     """
     lista = []
     gasit = self.__repo_asign.cauta_dupa_nrLab_nrPb(nrLab_nrPb)
     if len(gasit) != 0:
         for el in gasit:
             stud_ID = el.get_stud_ID()
             key_stud = Student(stud_ID, None, None)
             lista.append((self.__repo_stud.cauta(key_stud), el.get_nota()))
         lista.sort(key=lambda x: x[1])
     return lista
Beispiel #14
0
 def __ruleaza_teste_domeniu(self):
     studID = 2
     nume = "Alin"
     grup = 222
     student = Student(studID, nume, grup)
     assert student.get_stud_id() == studID
     assert student.get_nume() == nume
     assert student.get_grup() == grup
     assert str(student) == "2 : Alin : 222"
     alt_student = Student(studID, None, None)
     assert student == alt_student
Beispiel #15
0
 def generate(self, nr):
     """
     Genereaza automat nr studenti si ii adauga in repository
     :param: nr - numar natural
     :exception: Exception - in caul in care persoana generata este invalida
     """
     while nr > 0:
         studID = random.randrange(1, 100)
         nume = str("".join(random.choices(string.ascii_uppercase, k=7)))
         grup = random.randrange(1, 300)
         student = Student(studID, nume, grup)
         try:
             self.__valid.valideaza(student)
             self.__repo.adauga(student)
             nr = nr - 1
         except Exception:
             pass
Beispiel #16
0
 def __ruleaza_teste_serviciu_gaseste_stud_by_ID(self):
     repo = RepositoryStudenti()
     valid = Validare_Student()
     srv = ServiceStudenti(repo, valid)
     studID = 2
     nume = "Alina"
     grup = "233"
     student = Student(studID, nume, grup)
     repo.adauga(student)
     assert repo.size() == 1
     gasit = srv.gaseste_stud_by_ID(studID)
     assert gasit.get_nume() == "Alina"
     assert gasit.get_grup() == "233"
     try:
         srv.gaseste_stud_by_ID(3)
         assert False
     except RepoError as re:
         assert str(re) == "Element inexistent!\n"
Beispiel #17
0
    def adauga_stud_auto(self):
        """
        adauga studenti in repository
        """
        studenti = [0] * 6
        studenti[0] = Student(1, "Alina", 222)
        studenti[1] = Student(2, "Maria", 224)
        studenti[2] = Student(3, "Larisa", 226)
        studenti[3] = Student(4, "Daniel", 224)
        studenti[4] = Student(5, "Raluca", 223)
        studenti[5] = Student(6, "Alina", 228)

        for i in range(len(studenti)):
            self.__valid.valideaza(studenti[i])
            self.__repo.adauga(studenti[i])
    def raport_media_5(self):
        """
        Studentii cu media laboratoarelor mai mica de 5
        """
        dict_lab_notate = {}
        dict_total_note = {}
        lista_restantieri = []
        all_asgn = self.__repo_asign.get_all()
        for el in all_asgn:
            dict_lab_notate[el.get_stud_ID()] = 0
            dict_total_note[el.get_stud_ID()] = 0
        for el in all_asgn:
            dict_lab_notate[el.get_stud_ID()] += 1
            dict_total_note[el.get_stud_ID()] += el.get_nota()

        for el in dict_lab_notate:
            key_stud = Student(el, None, None)
            gasit = self.__repo_stud.cauta(key_stud)
            media = dict_total_note[el] / dict_lab_notate[el]
            if media < 5:
                lista_restantieri.append((gasit, media))
        return lista_restantieri
 def __ruleaza_teste_serviciu_adaugare(self):
     repo_asignare = RepositoryAsignare()
     repo_stud = RepositoryStudenti()
     repo_prob = RepositoryProbleme()
     valid = Validare_Asignare()
     srv = ServiceAsignare(repo_asignare, repo_stud, repo_prob, valid)
     student = Student(5, "Alina", "236")
     repo_stud.adauga(student)
     prob = Problema("4_18", "cam urata problema", 8)
     repo_prob.adauga(prob)
     asign_ID = 28
     stud_ID = 5
     nrLab_nrPb = "4_18"
     nota = 7
     srv.adauga_asignare(asign_ID, stud_ID, nrLab_nrPb, nota)
     assert srv.numar_asignare() == 1
     try:
         srv.adauga_asignare(-asign_ID, stud_ID, nrLab_nrPb,nota)
         assert False
     except ValidError as ve:
         assert str(ve) == "ID-ul asign nu poate fi un numar negativ!\n"
     try:
         srv.adauga_asignare(asign_ID, 5, "4_18", 8)
         assert False
     except RepoError as re:
         assert str(re) == "Element existent!\n"
     assert len(srv.get_asignare()) == 1
     try:
         srv.adauga_asignare(4, 5, "9_12", 8)
         assert False
     except RepoError as re:
         assert str(re) == "Element inexistent!\n"
     try:
         srv.adauga_asignare(4, 3, "9_12", 7)
         assert False
     except RepoError as re:
         assert str(re) == "Element inexistent!\n"