Beispiel #1
0
    def test_Enotare_asignare(self):
        # White-box testing pentru stergerea asignarilor din repository.

        s4 = Student(30, "Marin Stefania", 717)

        p4 = Problema(1, 7, "Programare dinamica",
                      repo_problema.Data("06.07.2021"))
        p5 = Problema(2, 3, "Management baza de date",
                      repo_problema.Data("02.12.2020"))
        p6 = Problema(4, 1, "Cont bancar", repo_problema.Data("09.01.2021"))

        repo_asignare.lista_asignari.notare_problema_file(s4, p4, 10)
        nota = repo_asignare.lista_asignari.readFromFile()[0].get_nota()
        assert nota == 10

        repo_asignare.lista_asignari.notare_problema_file(s4, p5, 7)
        nota = repo_asignare.lista_asignari.readFromFile()[1].get_nota()
        assert nota == 7

        repo_asignare.lista_asignari.notare_problema_file(
            repo_student.lista_stud.get_content()[1], p5, 9)
        nota = repo_asignare.lista_asignari.readFromFile()[2].get_nota()
        assert nota == 9

        repo_asignare.lista_asignari.notare_problema_file(
            repo_student.lista_stud.get_content()[1], p6, 3)
        nota = repo_asignare.lista_asignari.readFromFile()[3].get_nota()
        assert nota == 3
Beispiel #2
0
    def test_getters_asignare(self):
        # White-box testing: testez toate ramurile pentru getteri
        # (student, problema, nota si asignarea sub forma de tuple).

        s1, p1 = Student(1, "Pop Ion", 213), Problema(1, 1, "Cont bancar", "20.12.2020")
        a1 = Asignare(s1, p1)

        assert a1.get_nota() == 0
        assert a1.get_student() == Student(1, "Pop Ion", 213)
        assert a1.get_problema() == Problema(1, 1, "Cont bancar", "20.12.2020")

        a1.set_nota(9)
        assert a1.get_nota() == 9

        assert a1.get_asignare_tuple() == (Student(1, "Pop Ion", 213), Problema(1, 1, "Cont bancar", "20.12.2020"))
    def readFromFile(self):
        content = []
        file = open(self.__path, "r")

        line = file.readline()
        while line:
            line = line.strip()
            param = line.split("; ")

            if len(param) == 3:
                student = param[0].split(", ")
                problema = param[1].split(", ")
                nota = param[2]

                asignare = Asignare(
                    Student(int(student[0]), student[1], int(student[2])),
                    Problema(int(problema[0]), int(problema[1]), problema[2],
                             Data(problema[3])))

                asignare.set_nota(int(nota))

                content.append(asignare)

            line = file.readline()

        file.close()
        return content
Beispiel #4
0
    def srv_generare_problema(self):
        """
        Functia genereaza datele unei probleme, ce sunt returnate mai departe functiei de jos (pt. validare).
        """

        nr_lab = random.randint(1, 99)
        nr_prob = random.randint(1, 99)

        lista_litere = string.ascii_lowercase
        descriere = ''.join(random.choice(lista_litere) for i in range(20))

        zi = random.randint(1, 31)
        luna = random.randint(1, 12)
        an = random.randint(2020, 2023)

        deadline_string = ""
        if zi < 10:
            deadline_string += "0"
        deadline_string += str(zi) + "."

        if luna < 10:
            deadline_string += "0"
        deadline_string += str(luna) + "." + str(an)

        deadline = repo.Data(deadline_string)
        problema = Problema(nr_lab, nr_prob, descriere, deadline)

        return problema
Beispiel #5
0
    def test_setters_asignare(self):
        # White-box testing: testez toate ramurile pentru setteri, dar si pentru getteri
        # (student, problema si nota).

        s1, p1 = Student(1, "Pop Ion", 213), Problema(1, 1, "Cont bancar", "20.12.2020")
        nota = 7
        a1 = Asignare(0, 0)

        a1.set_nota(nota)
        assert a1.get_nota() == 7

        a1.set_student(s1)
        assert a1.get_student() == Student(1, "Pop Ion", 213)

        a1.set_problema(p1)
        assert a1.get_problema() == Problema(1, 1, "Cont bancar", "20.12.2020")
Beispiel #6
0
    def setUp(self):
        self.__a1 = Asignare(Student(1, "Farcasanu Stefan", 213),
                             Problema(1, 1, "Biblioteca", Data("05.04.2021")))
        self.__a2 = Asignare(Student(2, "Dina Andrei-Const", 213),
                             Problema(1, 1, "Biblioteca", Data("05.04.2021")))
        self.__a3 = Asignare(Student(3, "Dretcanu Mihai", 917),
                             Problema(1, 2, "Cinema", Data("18.12.2020")))
        self.__a4 = Asignare(Student(4, "Dretcanu Mihai", 313),
                             Problema(1, 2, "Cinema", Data("18.12.2020")))

        self.__a1.set_nota(6)
        self.__a2.set_nota(6)
        self.__a3.set_nota(10)
        self.__a4.set_nota(9)

        self.__d1 = [213, 2]
        self.__d2 = [313, 1]
Beispiel #7
0
    def test_Fstergere_asignare(self):
        # White-box testing pentru stergerea asignarilor din repository.

        p4 = Problema(1, 7, "Programare dinamica",
                      repo_problema.Data("06.07.2021"))
        p5 = Problema(2, 3, "Management baza de date",
                      repo_problema.Data("02.12.2020"))
        p6 = Problema(4, 1, "Cont bancar", repo_problema.Data("09.01.2021"))

        d4, d5 = repo_problema.Data("06.07.2021"), repo_problema.Data(
            "02.12.2020")
        d6 = repo_problema.Data("09.01.2021")

        repo_asignare.lista_asignari.stergere_asignare_file(p4, 0)
        content = repo_asignare.lista_asignari.readFromFile()
        assert content == [
            Asignare(Student(30, "Marin Stefania", 717),
                     Problema(2, 3, "Management baza de date", d5)),
            Asignare(Student(3, 'Alexandrescu Mihai', 917),
                     Problema(2, 3, "Management baza de date", d5)),
            Asignare(Student(3, 'Alexandrescu Mihai', 917),
                     Problema(4, 1, "Cont bancar", d6))
        ]

        repo_asignare.lista_asignari.stergere_asignare_file(p5, 0)
        content = repo_asignare.lista_asignari.readFromFile()
        assert content == [
            Asignare(Student(3, 'Alexandrescu Mihai', 917),
                     Problema(4, 1, "Cont bancar", d6))
        ]

        repo_asignare.lista_asignari.stergere_asignare_file(p6, 0)
        content = repo_asignare.lista_asignari.readFromFile()
        assert content == []
Beispiel #8
0
    def test_Aadaugare_asignare(self):
        # White-box testing pentru adaugarea asignarilor in repository.

        repo_asignare.lista_asignari.adaugare_asignare_file(self.a1)
        content = repo_asignare.lista_asignari.readFromFile()
        assert content == [
            Asignare(Student(15, 'Pop Ion', 213),
                     Problema(1, 1, 'Management baza de date', dl1))
        ]

        repo_asignare.lista_asignari.adaugare_asignare_file(self.a2)
        content = repo_asignare.lista_asignari.readFromFile()
        assert content == [
            Asignare(Student(15, 'Pop Ion', 213),
                     Problema(1, 1, 'Management baza de date', dl1)),
            Asignare(Student(15, 'Pop Ion', 213),
                     Problema(3, 1, 'Cheltuieli de familie', dl2))
        ]

        repo_asignare.lista_asignari.adaugare_asignare_file(self.a3)
        content = repo_asignare.lista_asignari.readFromFile()
        assert content == [
            Asignare(Student(15, 'Pop Ion', 213),
                     Problema(1, 1, 'Management baza de date', dl1)),
            Asignare(Student(15, 'Pop Ion', 213),
                     Problema(3, 1, 'Cheltuieli de familie', dl2)),
            Asignare(Student(3, 'Alexandrescu Mihai', 917),
                     Problema(3, 1, 'Cheltuieli de familie', dl3))
        ]

        repo_asignare.lista_asignari.adaugare_asignare_file(self.a4)
        content = repo_asignare.lista_asignari.readFromFile()
        assert content == [
            Asignare(Student(15, 'Pop Ion', 213),
                     Problema(1, 1, 'Management baza de date', dl1)),
            Asignare(Student(15, 'Pop Ion', 213),
                     Problema(3, 1, 'Cheltuieli de familie', dl2)),
            Asignare(Student(3, 'Alexandrescu Mihai', 917),
                     Problema(3, 1, 'Cheltuieli de familie', dl3)),
            Asignare(Student(3, 'Alexandrescu Mihai', 917),
                     Problema(2, 1, 'Cheltuieli service auto', dl4))
        ]
Beispiel #9
0
    def test_getters_problema(self):
        # White-box testing: testez toate ramurile pentru getteri
        # (nr. laborator, nr. problema, descriere, deadline, toate atributele si toate atributele fara deadline).

        dl1 = Data("11.12.2020")
        problema = Problema(1, 1, "Management baza de date", dl1)

        assert problema.get_nr_lab() == 1
        assert problema.get_nr_prob() == 1
        assert problema.get_descr() == "Management baza de date"
        assert problema.get_deadline() == dl1
        assert problema.get_all() == (1, 1, "Management baza de date", dl1)
        assert problema.get_all_dl() == (1, 1, "Management baza de date")
Beispiel #10
0
    def test_Bsrv_cautare_problema_Black_Box(self):
        # Black-box testing pentru service-ul de cautare a problemelor: adaug cateva probleme, pentru
        # a putea cauta indiferent de problemele introduse mai sus, in white-box testing.

        repo_problema.lista_prob.set_content([])

        srv_problema = ServiceProblema()
        srv_problema.srv_adaugare_problema("1, 1, Cheltuieli de familie, 09.12.2020")
        srv_problema.srv_adaugare_problema("1, 2, Catalog studenti, 31.01.2021")
        srv_problema.srv_adaugare_problema("16, 27, Mersul trenurilor, 28.02.2021")

        assert srv_problema.srv_cautare_problema("1 1") == \
               (1, 1, 'Cheltuieli de familie', repo_problema.Data("09.12.2020"))

        assert srv_problema.srv_cautare_problema("1 2") == (1, 2, "Catalog studenti", repo_problema.Data("31.01.2021"))

        assert srv_problema.srv_cautare_problema("16 27") == \
               (16, 27, "Mersul trenurilor", repo_problema.Data("28.02.2021"))

        self.assertRaises(NrLabError, srv_problema.srv_cautare_problema, "-16 27")
        self.assertRaises(NrLabError, srv_problema.srv_cautare_problema, "0 27")
        self.assertRaises(NrLabError, srv_problema.srv_cautare_problema, "n 27")
        self.assertRaises(NrProbError, srv_problema.srv_cautare_problema, "16 -27")
        self.assertRaises(NrProbError, srv_problema.srv_cautare_problema, "16 0")
        self.assertRaises(NrProbError, srv_problema.srv_cautare_problema, "16 l")
        self.assertRaises(ParamError, srv_problema.srv_cautare_problema, "16")
        self.assertRaises(ParamError, srv_problema.srv_cautare_problema, "16 27 8")
        self.assertRaises(ParamError, srv_problema.srv_cautare_problema, "")
        self.assertRaises(ExistentaError, srv_problema.srv_cautare_problema, "4 5")
        self.assertRaises(ExistentaError, srv_problema.srv_cautare_problema, "7 5")

        # Refacem content-ul dinaintea adaugarilor mele, pentru a merge restul testelor white-box.

        repo_problema.lista_prob.set_content([Problema(1, 1, 'Management cont bancar',
                                                       repo_problema.Data("18.12.2020")),
                                              Problema(1, 2, 'Mersul trenurilor', repo_problema.Data("30.04.2021")),
                                              Problema(2, 1, 'Problema grafuri', repo_problema.Data("24.11.2020"))])
Beispiel #11
0
    def test_Dstergere_problema(self):
        # White-box testing pentru stergerea problemelor din repository.

        dl6 = repo_problema.Data("05.04.2021")

        repo_problema.lista_prob.stergere_problema_file(3)
        content = repo_problema.lista_prob.readFromFile()
        assert content == [
            Problema(1, 1, "Baza de date studenti", dl1),
            Problema(1, 3, "Management biblioteca", dl2),
            Problema(2, 1, "Concurs de informatica", dl3),
            Problema(3, 1, "Management cinematograf", dl6)
        ]

        repo_problema.lista_prob.stergere_problema_file(0)
        content = repo_problema.lista_prob.readFromFile()
        assert content == [
            Problema(1, 3, "Management biblioteca", dl2),
            Problema(2, 1, "Concurs de informatica", dl3),
            Problema(3, 1, "Management cinematograf", dl6)
        ]

        repo_problema.lista_prob.stergere_problema_file(1)
        content = repo_problema.lista_prob.readFromFile()
        assert content == [
            Problema(1, 3, "Management biblioteca", dl2),
            Problema(3, 1, "Management cinematograf", dl6)
        ]

        repo_problema.lista_prob.stergere_problema_file(1)
        content = repo_problema.lista_prob.readFromFile()
        assert content == [Problema(1, 3, "Management biblioteca", dl2)]

        repo_problema.lista_prob.stergere_problema_file(0)
        content = repo_problema.lista_prob.readFromFile()
        assert content == []
Beispiel #12
0
    def setUp(self):
        student1 = Student(15, "Pop Ion", 213)
        student2 = Student(3, "Alexandrescu Mihai", 917)
        student3 = Student(5, "Ionescu Malina", 316)

        new_content = [student1, student2, student3]
        repo_student.lista_stud.set_content(new_content)

        problema1 = Problema(1, 1, "Management baza de date", dl1)
        problema2 = Problema(3, 1, "Cheltuieli de familie", dl2)
        problema3 = Problema(2, 1, "Cheltuieli service auto", dl3)
        problema4 = Problema(1, 3, "Baza de date studenti", dl4)

        new_content = [problema1, problema2, problema3, problema4]
        repo_problema.lista_prob.set_content(new_content)

        self.a1 = Asignare(repo_student.lista_stud.get_content()[0],
                           repo_problema.lista_prob.get_content()[0])
        self.a2 = Asignare(repo_student.lista_stud.get_content()[0],
                           repo_problema.lista_prob.get_content()[1])
        self.a3 = Asignare(repo_student.lista_stud.get_content()[1],
                           repo_problema.lista_prob.get_content()[1])
        self.a4 = Asignare(repo_student.lista_stud.get_content()[1],
                           repo_problema.lista_prob.get_content()[2])
Beispiel #13
0
    def readFromFile(self):
        content = []
        file = open(self.__path, "r")

        line = file.readline()
        while line:
            line = line.strip()
            param = line.split(", ")

            if len(param) == 4:
                content.append(
                    Problema(int(param[0]), int(param[1]), str(param[2]),
                             Data(str(param[3]))))

            line = file.readline()

        file.close()
        return content
Beispiel #14
0
    def test_setters_problema(self):
        # White-box testing: testez toate ramurile pentru setteri, dar si pentru getteri
        # (nr. laborator, nr. problema, descriere, deadline si toate atributele).

        dl1 = Data("04.03.2021")
        problema = Problema(0, 0, 0, 0)

        problema.set_nr_lab(2)
        problema.set_nr_prob(3)
        problema.set_descr("Mersul trenurilor")
        problema.set_deadline(dl1)

        assert problema.get_nr_lab() == 2
        assert problema.get_nr_prob() == 3
        assert problema.get_descr() == "Mersul trenurilor"
        assert problema.get_deadline() == dl1
        assert problema.get_all() == (2, 3, "Mersul trenurilor", dl1)
        assert problema.get_all_dl() == (2, 3, "Mersul trenurilor")

        dl2 = Data("28.02.2021")
        problema.set_all(7, 17, "Cont bancar", dl2)

        assert problema.get_nr_lab() == 7
        assert problema.get_nr_prob() == 17
        assert problema.get_descr() == "Cont bancar"
        assert problema.get_deadline() == dl2
        assert problema.get_all() == (7, 17, "Cont bancar", dl2)
        assert problema.get_all_dl() == (7, 17, "Cont bancar")
Beispiel #15
0
    def srv_adaugare_problema(self, intrare):
        """
        Functia primeste un sir de caractere, il valideaza, si daca este totul in regula, prelucreaza datele si
        le trimite in repo pentru adaugare.

        :param intrare: Un sir de caractere care ar trebui sa fie datele de intrare pentru problema.
        """

        validator_problema = ValidatorProblema()

        try:
            validator_problema.validare_problema(intrare)

            param = intrare.split(", ")
            repo.lista_prob.validare_unicitate_nr_prob(-1, param[0], param[1])

            nr_lab, nr_prob, descr = param[0], param[1], param[2]
            deadline = repo.Data(param[3])
            problema = Problema(0, 0, 0, 0)

            problema.set_nr_lab(nr_lab)
            problema.set_nr_prob(nr_prob)
            problema.set_descr(descr)
            problema.set_deadline(deadline)

            repo.lista_prob.adaugare_problema_file(problema)

        except NrLabError:
            raise NrLabError(
                "Numarul laboratorului este invalid! Introduceti alte date de intrare:"
            )

        except NrProbError:
            raise NrProbError(
                "Numarul problemei este invalid! Introduceti alte date de intrare:"
            )

        except DescrError:
            raise DescrError(
                "Descrierea problemei este invalida! Introduceti alte date de intrare:"
            )

        except DeadlineError:
            raise DeadlineError(
                "Formatul deadline-ului problemei este invalid! Introduceti alte date de intrare:"
            )

        except ZiError:
            raise ZiError(
                "Ziua deadline-ului este invalida! Introduceti alte date de intrare:"
            )

        except LunaError:
            raise LunaError(
                "Luna deadline-ului este invalida! Introduceti alte date de intrare:"
            )

        except AnError:
            raise AnError(
                "Anul deadline-ului este invalid! Introduceti alte date de intrare:"
            )

        except NrProbUnicError:
            raise NrProbUnicError(
                "Exista deja o problema cu acest numar la laboratorul acesta! Introduceti alte date de intrare:"
            )

        except ParamError:
            raise ParamError(
                "Parametri insuficienti! Introduceti alte date de intrare:")

        except ValueError:
            raise ValueError("Date de intrare invalide! Introduceti altele:")
Beispiel #16
0
    def srv_modificare_problema(self, nr_lab, nr_prob, intrare):
        """
        Functia primeste nr. laboratorlui si al problemei ce trebuie modificata si noile date de intrare. Dupa ce se
        asigura validitatea datelor de intrare, functia prelucreaza datele si le trimite in repo pentru a fi modificate.

        :param nr_lab: Numarul laboratorului din care face parte problema ce trebuie modificat, validat mai sus.
        :param nr_prob: Numarul problemei ce trebuie modificata, validat de functia de mai sus.
        :param intrare: Un sir de caractere ce ar trebui sa reprezinte noile date ale problemei.
        """

        validator_problema = ValidatorProblema()

        try:
            validator_problema.validare_problema(intrare)

            param = intrare.split(", ")

            index_problema_gasita = repo.lista_prob.cautare_problema(
                len(repo.lista_prob.get_content()) - 1, nr_lab, nr_prob)

            repo.lista_prob.validare_unicitate_nr_prob(index_problema_gasita,
                                                       param[0], param[1])

            nr_lab, nr_prob, descr = param[0], param[1], param[2]
            deadline = repo.Data(param[3])
            problema = Problema(0, 0, 0, 0)

            problema.set_nr_lab(nr_lab)
            problema.set_nr_prob(nr_prob)
            problema.set_descr(descr)
            problema.set_deadline(deadline)

            repo_asignare.lista_asignari.modificare_asignare_file(
                repo.lista_prob.get_content()[index_problema_gasita], problema,
                0)
            repo.lista_prob.modificare_problema_file(index_problema_gasita,
                                                     problema)

        except NrLabError:
            raise NrLabError(
                "Noul numar al laboratorului este invalid! Introduceti alte date de intrare:"
            )

        except NrProbError:
            raise NrProbError(
                "Noul numar al problemei este invalid! Introduceti alte date de intrare:"
            )

        except DescrError:
            raise DescrError(
                "Noua descriere a problemei este invalida! Introduceti alte date de intrare:"
            )

        except DeadlineError:
            raise DeadlineError(
                "Noul format al deadline-ului este invalid! Introduceti alte date de intrare:"
            )

        except ZiError:
            raise ZiError(
                "Noua zi a deadline-ului este invalida! Introduceti alte date de intrare:"
            )

        except LunaError:
            raise LunaError(
                "Noua luna a deadline-ului este invalida! Introduceti alte date de intrare:"
            )

        except AnError:
            raise AnError(
                "Noul an al deadline-ului este invalid! Introduceti alte date de intrare:"
            )

        except NrProbUnicError:
            raise NrProbUnicError(
                "Exista deja o problema cu acest numar la laboratorul acesta! Introduceti alte date de intrare:"
            )

        except ParamError:
            raise ParamError(
                "Noii parametri sunt insuficienti! Introduceti alte date de intrare:"
            )

        except ValueError:
            raise ValueError(
                "Noile date de intrare sunt invalide! Introduceti altele:")
Beispiel #17
0
    def test_Aadaugare_problema(self):
        # White-box testing pentru adaugarea problemelor in repository.

        problema = Problema(1, 1, "Baza de date", dl1)

        repo_problema.lista_prob.adaugare_problema_file(problema)
        content = repo_problema.lista_prob.readFromFile()
        assert content == [Problema(1, 1, "Baza de date", dl1)]

        problema = Problema(1, 2, "Management biblioteca", dl2)

        repo_problema.lista_prob.adaugare_problema_file(problema)
        content = repo_problema.lista_prob.readFromFile()
        assert content == [
            Problema(1, 1, "Baza de date", dl1),
            Problema(1, 2, "Management biblioteca", dl2)
        ]

        problema = Problema(2, 1, "Concurs de informatica", dl3)

        repo_problema.lista_prob.adaugare_problema_file(problema)
        content = repo_problema.lista_prob.readFromFile()
        assert content == [
            Problema(1, 1, "Baza de date", dl1),
            Problema(1, 2, "Management biblioteca", dl2),
            Problema(2, 1, "Concurs de informatica", dl3)
        ]

        problema = Problema(2, 2, "Catalog studenti", dl4)

        repo_problema.lista_prob.adaugare_problema_file(problema)
        content = repo_problema.lista_prob.readFromFile()
        assert content == [
            Problema(1, 1, "Baza de date", dl1),
            Problema(1, 2, "Management biblioteca", dl2),
            Problema(2, 1, "Concurs de informatica", dl3),
            Problema(2, 2, "Catalog studenti", dl4)
        ]

        problema = Problema(2, 3, "Management cont bancar", dl5)

        repo_problema.lista_prob.adaugare_problema_file(problema)
        content = repo_problema.lista_prob.readFromFile()
        assert content == [
            Problema(1, 1, "Baza de date", dl1),
            Problema(1, 2, "Management biblioteca", dl2),
            Problema(2, 1, "Concurs de informatica", dl3),
            Problema(2, 2, "Catalog studenti", dl4),
            Problema(2, 3, "Management cont bancar", dl5)
        ]
Beispiel #18
0
    def test_Dmodificare_asignare(self):
        # White-box testing pentru modificarea asignarilor din repository.

        p1, d1 = repo_problema.lista_prob.get_content(
        )[0], repo_problema.lista_prob.get_content()[0].get_deadline
        p2, d2 = repo_problema.lista_prob.get_content(
        )[1], repo_problema.lista_prob.get_content()[1].get_deadline
        p3, d3 = repo_problema.lista_prob.get_content(
        )[2], repo_problema.lista_prob.get_content()[2].get_deadline

        d4, d5 = repo_problema.Data("06.07.2021"), repo_problema.Data(
            "02.12.2020")
        d6 = repo_problema.Data("09.01.2021")

        p4 = Problema(1, 7, "Programare dinamica", d4)
        p5 = Problema(2, 3, "Management baza de date", d5)
        p6 = Problema(4, 1, "Cont bancar", d6)

        repo_asignare.lista_asignari.modificare_asignare_file(p1, p4, 0)
        content = repo_asignare.lista_asignari.readFromFile()
        assert content == [
            Asignare(Student(15, 'Pop Ion', 213),
                     Problema(1, 7, 'Programare dinamica', d4)),
            Asignare(Student(15, 'Pop Ion', 213),
                     Problema(3, 1, 'Cheltuieli de familie', d2)),
            Asignare(Student(3, 'Alexandrescu Mihai', 917),
                     Problema(3, 1, 'Cheltuieli de familie', d2)),
            Asignare(Student(3, 'Alexandrescu Mihai', 917),
                     Problema(2, 1, 'Cheltuieli service auto', d3))
        ]

        repo_asignare.lista_asignari.modificare_asignare_file(p2, p5, 0)
        content = repo_asignare.lista_asignari.readFromFile()
        assert content == [
            Asignare(Student(15, 'Pop Ion', 213),
                     Problema(1, 7, 'Programare dinamica', d4)),
            Asignare(Student(15, 'Pop Ion', 213),
                     Problema(2, 3, "Management baza de date", d5)),
            Asignare(Student(3, 'Alexandrescu Mihai', 917),
                     Problema(2, 3, "Management baza de date", d5)),
            Asignare(Student(3, 'Alexandrescu Mihai', 917),
                     Problema(2, 1, 'Cheltuieli service auto', d3))
        ]

        repo_asignare.lista_asignari.modificare_asignare_file(p3, p6, 0)
        content = repo_asignare.lista_asignari.readFromFile()
        assert content == [
            Asignare(Student(15, 'Pop Ion', 213),
                     Problema(1, 7, 'Programare dinamica', d4)),
            Asignare(Student(15, 'Pop Ion', 213),
                     Problema(2, 3, "Management baza de date", d5)),
            Asignare(Student(3, 'Alexandrescu Mihai', 917),
                     Problema(2, 3, "Management baza de date", d5)),
            Asignare(Student(3, 'Alexandrescu Mihai', 917),
                     Problema(4, 1, "Cont bancar", d6))
        ]

        s1 = repo_student.lista_stud.get_content()[0]
        s4 = Student(30, "Marin Stefania", 717)

        repo_asignare.lista_asignari.modificare_asignare_file(s1, s4, 1)
        content = repo_asignare.lista_asignari.readFromFile()
        assert content == [
            Asignare(Student(30, "Marin Stefania", 717),
                     Problema(1, 7, 'Programare dinamica', d4)),
            Asignare(Student(30, "Marin Stefania", 717),
                     Problema(2, 3, "Management baza de date", d5)),
            Asignare(Student(3, 'Alexandrescu Mihai', 917),
                     Problema(2, 3, "Management baza de date", d5)),
            Asignare(Student(3, 'Alexandrescu Mihai', 917),
                     Problema(4, 1, "Cont bancar", d6))
        ]
Beispiel #19
0
    def test_Cmodificare_problema(self):
        # White-box testing pentru modificarea problemelor din repository.

        problema_noua = Problema(1, 1, 'Baza de date studenti', dl1)
        repo_problema.lista_prob.modificare_problema_file(0, problema_noua)
        content = repo_problema.lista_prob.readFromFile()
        assert content == [
            Problema(1, 1, "Baza de date studenti", dl1),
            Problema(1, 2, "Management biblioteca", dl2),
            Problema(2, 1, "Concurs de informatica", dl3),
            Problema(2, 2, "Catalog studenti", dl4),
            Problema(2, 3, "Management cont bancar", dl5)
        ]

        problema_noua = Problema(1, 3, "Management biblioteca", dl2)
        repo_problema.lista_prob.modificare_problema_file(1, problema_noua)
        content = repo_problema.lista_prob.readFromFile()
        assert content == [
            Problema(1, 1, "Baza de date studenti", dl1),
            Problema(1, 3, "Management biblioteca", dl2),
            Problema(2, 1, "Concurs de informatica", dl3),
            Problema(2, 2, "Catalog studenti", dl4),
            Problema(2, 3, "Management cont bancar", dl5)
        ]

        dl6 = repo_problema.Data("05.04.2021")
        problema_noua = Problema(3, 1, "Management cinematograf", dl6)
        repo_problema.lista_prob.modificare_problema_file(4, problema_noua)
        content = repo_problema.lista_prob.readFromFile()
        assert content == [
            Problema(1, 1, "Baza de date studenti", dl1),
            Problema(1, 3, "Management biblioteca", dl2),
            Problema(2, 1, "Concurs de informatica", dl3),
            Problema(2, 2, "Catalog studenti", dl4),
            Problema(3, 1, "Management cinematograf", dl6)
        ]

        problema_noua = Problema(2, 3, "Catalog studenti", dl5)
        repo_problema.lista_prob.modificare_problema_file(3, problema_noua)
        content = repo_problema.lista_prob.readFromFile()
        assert content == [
            Problema(1, 1, "Baza de date studenti", dl1),
            Problema(1, 3, "Management biblioteca", dl2),
            Problema(2, 1, "Concurs de informatica", dl3),
            Problema(2, 3, "Catalog studenti", dl5),
            Problema(3, 1, "Management cinematograf", dl6)
        ]

        problema_noua = Problema(2, 2, "Mersul trenurilor", dl4)
        repo_problema.lista_prob.modificare_problema_file(3, problema_noua)
        content = repo_problema.lista_prob.readFromFile()
        assert content == [
            Problema(1, 1, "Baza de date studenti", dl1),
            Problema(1, 3, "Management biblioteca", dl2),
            Problema(2, 1, "Concurs de informatica", dl3),
            Problema(2, 2, "Mersul trenurilor", dl4),
            Problema(3, 1, "Management cinematograf", dl6)
        ]