Ejemplo n.º 1
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"
Ejemplo n.º 2
0
 def repo_adauga_student(self):
     student = Student(25, "laris")
     repo_stud = Repo()
     assert repo_stud.size() == 0
     repo_stud.adauga(student)
     assert repo_stud.size() == 1
     student = Student(25, "lala")
     try:
         repo_stud.adauga(student)
         assert False
     except RepoError as re:
         assert str(re) == "item deja existent!\n"
Ejemplo n.º 3
0
    def test_adaug_nota(self):
        nota = Nota(1, 5, 7)
        repo = Repo()
        assert repo.size() == 0
        repo.adauga(nota)
        assert repo.size() == 1

        try:
            repo.adauga(nota)
            assert False
        except RepoError as re:
            assert str(re) == "item deja existent!\n"
Ejemplo n.º 4
0
 def modifica_student(self):
     student = Student(25, "laris")
     repo_stud = Repo()
     repo_stud.adauga(student)
     nume_change = "Andrei"
     cheie_stud = Student(24, None)
     try:
         repo_stud.cauta(cheie_stud)
         assert False
     except RepoError as re:
         assert str(re) == "item inexistent"
     cheie_stud = Student(25, None)
     stud_gasit = repo_stud.cauta(cheie_stud)
     repo_stud.modifica(stud_gasit, nume_change)
     assert repo_stud.cauta(stud_gasit).get_nume() == nume_change
Ejemplo n.º 5
0
    def caut_stud(self):
        student = Student(1, "Andrei")
        repo = Repo()

        repo.adauga(student)
        cheie = Student(2, None)

        try:
            repo.cauta(cheie)
            assert False
        except RepoError as re:
            assert str(re) == "item inexistent"
        cheie = Student(1, None)
        gasit = repo.cauta(cheie)
        assert gasit.get_id() == 1
        assert gasit.get_nume() == "Andrei"
Ejemplo n.º 6
0
    def repo_delete_student(self):
        student = Student(25, "andrei")
        repo = Repo()

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

        cheie_student = Student(25, None)
        repo.delete(cheie_student)
        assert repo.size() == 0
Ejemplo n.º 7
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
Ejemplo n.º 8
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"
Ejemplo n.º 9
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
Ejemplo n.º 10
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"