예제 #1
0
 def test_repoUndo(self):
     repoUndo = RepositoryUndo()
     try:
         repoUndo.peek()
         assert False
     except RepoError as re:
         assert str(re) == "Undo indisponibil!"
     repoStud = RepositoryStud()
     cmd_undo = repoStud.sterge_stud
     cmd_redo = repoStud.adauga_stud
     id_stud = 1
     nume_stud = "Dorin"
     stud = Student(id_stud, nume_stud)
     actUndo = ActiuneUndo(cmd_undo, cmd_redo, id_stud, stud)
     repoUndo.push(actUndo)
     assert len(repoUndo) == 1
     assert repoUndo.peek() == actUndo
     cmd_undo2 = repoStud.adauga_stud
     cmd_redo2 = repoStud.sterge_stud
     id_stud2 = 2
     nume_stud2 = "Dorin2"
     stud2 = Student(id_stud2, nume_stud2)
     actUndo2 = ActiuneUndo(cmd_undo2, cmd_redo2, stud2, id_stud2)
     repoUndo.push(actUndo2)
     assert len(repoUndo) == 2
     assert repoUndo.peek() == actUndo2
     repoUndo.pop()
     assert len(repoUndo) == 1
     cmd_undo3 = repoStud.modifica_stud
     cmd_redo3 = repoStud.modifica_stud
     id_stud3 = 1
     nume_stud3 = "Dorin3"
     stud3_precedent = Student(id_stud3, nume_stud)
     stud3 = Student(id_stud3, nume_stud3)
     actUndo3 = ActiuneUndo(cmd_undo3, cmd_redo3, stud3_precedent, stud3)
     repoUndo.push(actUndo3)
     assert len(repoUndo) == 2
     assert repoUndo.peek() == actUndo3
     try:
         repoUndo.pull()
         assert False
     except RepoError as re:
         assert str(re) == "Redo indisponibil!"
     repoUndo.pop()
     assert len(repoUndo) == 1
     repoUndo.pop()
     assert len(repoUndo) == 0
     try:
         repoUndo.peek()
         assert False
     except RepoError as re:
         assert str(re) == "Undo indisponibil!"
     repoUndo.pull()
     assert len(repoUndo) == 1
예제 #2
0
 def modifica_disc(self, id_disc, nume_disc, nume_prof):
     disc_precedent, disc = ServiceDisc.modifica_disc(
         self, id_disc, nume_disc, nume_prof)
     act_undo = ActiuneUndo(self._repoDisc.modifica_disc,
                            self._repoDisc.modifica_disc, disc_precedent,
                            disc)
     self._repoUndo.push(act_undo)
예제 #3
0
 def modifica_stud(self, id_stud, nume_stud_modif):
     stud_precedent, stud_modif = ServiceStud.modifica_stud(
         self, id_stud, nume_stud_modif)
     act_undo = ActiuneUndo(self._repoStud.modifica_stud,
                            self._repoStud.modifica_stud, stud_precedent,
                            stud_modif)
     self._repoUndo.push(act_undo)
예제 #4
0
 def test_domeniuUndo(self):
     repoStud = RepositoryStud()
     cmd_undo = repoStud.sterge_stud
     cmd_redo = repoStud.adauga_stud
     id_stud = 1
     nume_stud = "Dorin"
     stud = Student(id_stud, nume_stud)
     actUndo = ActiuneUndo(cmd_undo, cmd_redo, id_stud, stud)
     assert actUndo.get_cmd_undo() == cmd_undo
     assert actUndo.get_cmd_redo() == cmd_redo
     assert actUndo.get_entitate_undo() == id_stud
     assert actUndo.get_entitate_redo() == stud
예제 #5
0
 def adauga_disc(self, id_disc, nume_disc, nume_prof):
     disc = ServiceDisc.adauga_disc(self, id_disc, nume_disc, nume_prof)
     act_undo = ActiuneUndo(self._repoDisc.sterge_disc,
                            self._repoDisc.adauga_disc, id_disc, disc)
     self._repoUndo.push(act_undo)
예제 #6
0
 def sterge_stud(self, id_stud):
     stud = ServiceStud.sterge_stud(self, id_stud)
     act_undo = ActiuneUndo(self._repoStud.adauga_stud,
                            self._repoStud.sterge_stud, stud, id_stud)
     self._repoUndo.push(act_undo)