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 sterge_probleme(self, nrLab_nrPb):
     """
     sterge o pb dupa nrLab_nrPb
     :param: nrLab_nrPb - string ( identificator unic al unei pb)
     """
     key_pb = Problema(nrLab_nrPb, None, None)
     self.__repo.sterge(key_pb)
 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 #5
0
    def __ruleaza_teste_repo(self):
        # adaugare
        repo = RepositoryProbleme()
        assert repo.size() == 0
        nrLab_nrPb = "3_2"
        desc = "nu-mi place"
        deadline = "7"
        problema = Problema(nrLab_nrPb, desc, deadline)
        repo.adauga(problema)
        assert repo.size() == 1

        # cautare
        key_pb = Problema(nrLab_nrPb, None, None)
        gasit = repo.cauta(key_pb)
        try:
            repo.adauga(key_pb)
            assert False
        except RepoError as re:
            assert str(re) == "Problema existenta!\n"
        assert gasit.get_desc() == desc
        key_pb_nu = Problema("24", None, None)
        try:
            repo.cauta(key_pb_nu)
            assert False
        except RepoError as re:
            assert str(re) == "Element inexistent!\n"

        # modificare
        pb_noua = Problema("13_5", "merge", 14)
        repo.adauga(pb_noua)
        repo.modifica(pb_noua)
        gasit = repo.cauta(pb_noua)
        assert gasit.get_desc() == "merge"
        try:
            repo.modifica(key_pb_nu)
            assert False
        except RepoError as re:
            assert str(re) == "Element inexistent!\n"

        # stergere si size
        repo.sterge(key_pb)
        assert repo.size() == 1
        try:
            repo.sterge(key_pb)
            assert False
        except RepoError as re:
            assert str(re) == "Element inexistent!\n"
Beispiel #6
0
 def gaseste_pb_by_nrPb(self, nrLab_nrPb):
     """
     Gaseste o problema dupa nrLab_nrPb
     :param: nrLab_nrPb - string ( identificator unic al unei probleme)
     :return: Problema (obiectul problema cu datele cautate)
     """
     key_pb = Problema(nrLab_nrPb, None, None)
     return self.__repo.cauta(key_pb)
Beispiel #7
0
    def adauga_probleme_auto(self):
        """
        adauga probleme in repository
        """
        probleme = [0] * 10
        probleme[0] = Problema("12_2", "misterioasa", 15)
        probleme[1] = Problema("12_3", "misterioasa", 15)
        probleme[2] = Problema("12_4", "misterioasa", 18)
        probleme[3] = Problema("12_5", "misterioasa", 15)
        probleme[4] = Problema("12_6", "misterioasa", 15)
        probleme[5] = Problema("11_2", "misterioasa", 15)
        probleme[6] = Problema("8_2", "misterioasa", 15)
        probleme[7] = Problema("7_1", "misterioasa", 15)
        probleme[8] = Problema("3_8", "de groaza", 7)
        probleme[9] = Problema("10_1", "foarte grea", 12)

        for i in range(len(probleme)):
            self.__valid.valideaza(probleme[i])
            self.__repo.adauga(probleme[i])
Beispiel #8
0
 def modifica_pb(self, nrLab_nrPb, desc, deadline):
     """
     modifica descrierea si deadline-ul unei pb existente (dupa nrLab_nrPb)
     :param: nrLab_nrPb - string ( identificator unic al unui eveniment)
     :param: description - string
     :param: deadline - int
     """
     pb_noua = Problema(nrLab_nrPb, desc, deadline)
     self.__valid.valideaza(pb_noua)
     self.__repo.modifica(pb_noua)
Beispiel #9
0
 def adauga_problema(self, nrLab_nrPb, desc, deadline):
     """
     adauga o problema
     :param: nrLab_nrPb - string
     :param: desc - string
     :param: deadline - int > 0
     """
     problema = Problema(nrLab_nrPb, desc, deadline)
     self.__valid.valideaza(problema)
     self.__repo.adauga(problema)
Beispiel #10
0
 def __ruleaza_teste_validare(self):
     nrLab_nrPb = ""
     desc = "ok"
     deadline = -2
     problema = Problema(nrLab_nrPb, desc, deadline)
     valid = Validare_Problema()
     try:
         valid.valideaza(problema)
         assert False
     except ValidError as ve:
         assert str(
             ve
         ) == "ID-ul nu poate fi gol!\nDeadline-ul nu poate fi un numar negativ!\n"
Beispiel #11
0
 def __ruleaza_teste_serviciu_modificare(self):
     repo = RepositoryProbleme()
     valid = Validare_Problema()
     srv = ServiceProbleme(repo, valid)
     nrLab_nrPb = "2_1"
     desc = "super"
     deadline = 6
     pb = Problema(nrLab_nrPb, desc, deadline)
     repo.adauga(pb)
     assert srv.numar_probleme() == 1
     assert repo.size() == 1
     desc_noua = "nu e chiar super"
     deadline_nou = 5
     srv.modifica_pb(nrLab_nrPb, desc_noua, deadline_nou)
     key_pb = Problema(nrLab_nrPb, None, None)
     gasit = repo.cauta(key_pb)
     assert gasit.get_desc() == "nu e chiar super"
     assert gasit.get_deadline() == 5
     try:
         srv.modifica_pb(3, desc_noua, deadline_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)
Beispiel #13
0
 def __ruleaza_teste_domeniu(self):
     nrLab_nrPb = "2_7"
     desc = "interesanta"
     deadline = 6
     problema = Problema(nrLab_nrPb, desc, deadline)
     assert problema.get_nrLab_nrPb() == nrLab_nrPb
     assert problema.get_desc() == desc
     assert problema.get_deadline() == deadline
     assert str(problema) == "2_7 : interesanta : 6"
     alta_pb = Problema(nrLab_nrPb, None, None)
     assert problema == alta_pb
Beispiel #14
0
 def generate(self, nr):
     """
     Genereaza automat nr probleme si le adauga in repository
     :param: nr - numar natural
     :exception: Exception - in cazul in care problema generata este invalida
     """
     while nr > 0:
         nrLab_nrPb = random.randrange(1, 10)
         desc = str("".join(random.choices(string.ascii_uppercase, k=14)))
         deadline = random.randrange(nrLab_nrPb + 1, 20)
         problema = Problema(nrLab_nrPb, desc, deadline)
         try:
             self.__valid.valideaza(problema)
             self.__repo.adauga(problema)
             nr = nr - 1
         except Exception:
             pass
Beispiel #15
0
 def __ruleaza_teste_serviciu_gaseste_pb_by_nrLab_nrPb(self):
     repo = RepositoryProbleme()
     valid = Validare_Problema()
     srv = ServiceProbleme(repo, valid)
     nrLab_nrPb = "3_6"
     desc = "ok"
     deadline = 6
     pb = Problema(nrLab_nrPb, desc, deadline)
     repo.adauga(pb)
     assert srv.numar_probleme() == 1
     assert repo.size() == 1
     gasit = srv.gaseste_pb_by_nrPb(nrLab_nrPb)
     assert gasit.get_desc() == "ok"
     assert gasit.get_deadline() == 6
     try:
         srv.gaseste_pb_by_nrPb(3)
         assert False
     except RepoError as re:
         assert str(re) == "Element inexistent!\n"
Beispiel #16
0
 def __ruleaza_teste_serviciu_sterge(self):
     repo = RepositoryProbleme()
     valid = Validare_Problema()
     srv = ServiceProbleme(repo, valid)
     nrLab_nrPb = "12_11"
     desc = "se putea mai bine"
     deadline = 14
     pb = Problema(nrLab_nrPb, desc, deadline)
     repo.adauga(pb)
     assert srv.numar_probleme() == 1
     srv.adauga_problema("13_4", "bine", 16)
     assert srv.numar_probleme() == 2
     srv.sterge_probleme(nrLab_nrPb)
     assert srv.numar_probleme() == 1
     try:
         srv.sterge_probleme("4_1")
         assert False
     except RepoError as re:
         assert str(re) == "Element inexistent!\n"
 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"
 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