Пример #1
0
    def repo_delete_disciplina(self):
        disciplina = Disciplina(25, "andrei", "romana")
        repo = Repo()

        repo.adauga(disciplina)
        assert repo.size() == 1
        cheie_disciplina = Disciplina(24, None, None)
        try:
            repo.delete(cheie_disciplina)
            assert False
        except RepoError as re:
            assert str(re) == "item inexistent"

        cheie_disciplina = Disciplina(25, None, None)
        repo.delete(cheie_disciplina)
        assert repo.size() == 0
Пример #2
0
    def caut_disciplina(self):
        disciplina = Disciplina(25, "andrei", "romana")
        repo = Repo()

        repo.adauga(disciplina)
        cheie = Disciplina(23, "andrei", "romana")

        try:
            repo.cauta(cheie)
            assert False
        except RepoError as re:
            assert str(re) == "item inexistent"
        cheie = Disciplina(25, "andrei", "romana")
        gasit = repo.cauta(cheie)
        assert gasit.get_id() == 25
        assert gasit.get_nume() == "romana"
        assert gasit.get_materie() == "andrei"
Пример #3
0
 def modifica_disciplina(self):
     disciplina = Disciplina(25, "mate", "ladla")
     repo = Repo()
     repo.adauga(disciplina)
     nume_change = "Andrei"
     materie_change = "info"
     cheie_disciplina = Disciplina(24, None, None)
     try:
         repo.cauta(cheie_disciplina)
         assert False
     except RepoError as re:
         assert str(re) == "item inexistent"
     cheie_disciplina = Disciplina(25, None, None)
     disciplina_gasita = repo.cauta(cheie_disciplina)
     repo.modifica(disciplina_gasita, nume_change)
     repo.modifica_materie(disciplina_gasita, materie_change)
     assert repo.cauta(disciplina_gasita).get_nume() == nume_change
     assert repo.cauta(disciplina_gasita).get_materie() == materie_change
Пример #4
0
 def repo_adauga_disciplina(self):
     disciplina = Disciplina(1, "mate", "berinde")
     repo = Repo()
     assert repo.size() == 0
     repo.adauga(disciplina)
     try:
         repo.adauga(disciplina)
         assert False
     except RepoError as re:
         assert str(re) == "item deja existent!\n"
Пример #5
0
    def valideaza_disciplina(self):
        disValida = Disciplina(1, "Mate", "stoica")
        dis_id_invalid = Disciplina(-1, "mate", "stoica")
        dis_materie_invalida = Disciplina(1, "", "stoica")
        dis_nume_invalid = Disciplina(1, "mate", "")

        valid_disciplina = ValidatorDisciplina()

        valid_disciplina.valideaza_disciplina(disValida)
        try:
            valid_disciplina.valideaza_disciplina(dis_id_invalid)
            assert False
        except ValidError as ve:
            assert str(ve) == "id invalid!\n"
        try:
            valid_disciplina.valideaza_disciplina(dis_materie_invalida)
            assert False
        except ValidError as ve:
            assert str(ve) == "materie invalida!\n"
        try:
            valid_disciplina.valideaza_disciplina(dis_nume_invalid)
            assert False
        except ValidError as ve:
            assert str(ve) == "nume invalid!\n"
Пример #6
0
    def test_validare_nota(self):
        nota_negativa = Nota(1, -3, 2)
        nota_prea_mare = Nota(1, 12, 2)
        nota_student_inexistent = Nota(5, 7, 2)
        nota_disc_inexistenta = Nota(1, 7, 3)
        nota = Nota(1, 3, 2)
        stud = Student(1, "Japonia")
        repo_stud = Repo()
        repo_stud.adauga(stud)
        disc = Disciplina(2, "mate", "info")
        repo_disc = Repo()
        repo_disc.adauga(disc)

        valid = ValidatorNote()

        valid.valideaza_note(
            nota, repo_stud.exista(Student(nota.get_student(), None)),
            repo_disc.exista(Disciplina(nota.get_id_disciplina(), None, None)))
        try:
            valid.valideaza_note(
                nota_negativa,
                repo_stud.exista(Student(nota_negativa.get_student(), None)),
                repo_disc.exista(
                    Disciplina(nota_negativa.get_id_disciplina(), None, None)))
            assert False
        except ValidError as ve:
            assert str(ve) == "nota nu poate fi negativa\n"

        try:
            valid.valideaza_note(
                nota_prea_mare,
                repo_stud.exista(Student(nota_prea_mare.get_student(), None)),
                repo_disc.exista(
                    Disciplina(nota_prea_mare.get_id_disciplina(), None,
                               None)))
            assert False
        except ValidError as ve:
            assert str(ve) == "nota nu poate fi mai mare decat 10\n"

        try:
            valid.valideaza_note(
                nota_student_inexistent,
                repo_stud.exista(
                    Student(nota_student_inexistent.get_student(), None)),
                repo_disc.exista(
                    Disciplina(nota_student_inexistent.get_id_disciplina(),
                               None, None)))
            assert False
        except ValidError as ve:
            assert str(
                ve) == "nota nu poate fi data la un student inexistent\n"
        try:
            valid.valideaza_note(
                nota_disc_inexistenta,
                repo_stud.exista(
                    Student(nota_disc_inexistenta.get_student(), None)),
                repo_disc.exista(
                    Disciplina(nota_disc_inexistenta.get_id_disciplina(), None,
                               None)))
            assert False
        except ValidError as ve:
            assert str(
                ve) == "nota nu poate fi data la o materie inexistenta\n"
Пример #7
0
    def creeaza_disciplina(self):
        dis1 = Disciplina(1, "Mate", "stoica")

        assert dis1.get_id() == 1
        assert dis1.get_materie() == "Mate"
        assert dis1.get_nume() == "stoica"

        dis1.set_materie("Info")
        assert dis1.get_materie() == "Info"

        dis1.set_nume("Gabi")
        assert dis1.get_nume() == "Gabi"

        dis2 = Disciplina(1, "info", "lala")

        assert dis1 == dis2
Пример #8
0
 def adauga_disciplina(self, id_disc, materie, nume):
     disciplina = Disciplina(id_disc, materie, nume)
     self.__validDisciplina.valideaza_disciplina(disciplina)
     self.__repoDisciplina.adauga(disciplina)
Пример #9
0
 def caut_disciplina(self, d_id):
     cheie = Disciplina(d_id, None, None)
     self.__validDisciplina.valideaza_disciplina(cheie)
     return self.__repoDisciplina.cauta(cheie)
Пример #10
0
 def delete_disciplina(self, s_id):
     cheie = Disciplina(s_id, "NONE", "NONE")
     self.__validDisciplina.valideaza_disciplina(cheie)
     self.__repoDisciplina.delete(cheie)
Пример #11
0
 def modify_nume(self, d_id, name_change):
     cheie = Disciplina(d_id, "NONE", "NONE")
     self.__validDisciplina.valideaza_disciplina(cheie)
     self.__repoDisciplina.modifica(cheie, name_change)
Пример #12
0
 def modify_materie(self, d_id, materie_change):
     cheie = Disciplina(d_id, "NONE", "NONE")
     self.__validDisciplina.valideaza_disciplina(cheie)
     self.__repoDisciplina.modifica_materie(cheie, materie_change)