def test_studetController(self): repoStudents = StudentRepo('studentstest', Student.write_student, Student.read_student) studentController = StudentController(repoStudents) studentController.create(1, 'Name', 'Group') self.assertEqual(studentController.repo.getAll()[0], Student(1, 'Name', 'Group')) studentController.remove(1) self.assertEqual(len(studentController.repo.getAll()), 0)
def setUp(self): repo = StudentBase() undo = UndoController() self.ctrl = StudentController(repo, undo)
class Test(unittest.TestCase): def setUp(self): repo = StudentBase() undo = UndoController() self.ctrl = StudentController(repo, undo) def testAdd(self): self.assertEqual(len(self.ctrl.getAll()), 0) s = Student(1, 'mark') self.ctrl.addStudent(s) self.assertEqual(len(self.ctrl.getAll()), 1) l = self.ctrl.getAll() self.assertEqual(l[0].getId(), 1) self.assertEqual(l[0].getName(), 'mark') def testFindById(self): self.assertEqual(len(self.ctrl.getAll()), 0) s = Student(1, 'mark') self.ctrl.addStudent(s) s2 = self.ctrl.findById(1) self.assertEqual(len(self.ctrl.getAll()), 1) l = self.ctrl.getAll() self.assertEqual(s.getId(), s2.getId()) self.assertEqual(s.getName(), s2.getName()) def testRemove(self): self.assertEqual(len(self.ctrl.getAll()), 0) s = Student(1, 'mark') self.ctrl.addStudent(s) self.assertEqual(len(self.ctrl.getAll()), 1) l = self.ctrl.getAll() self.assertEqual(l[0].getId(), 1) self.assertEqual(l[0].getName(), 'mark') s2 = Student(2, 'ana') self.ctrl.addStudent(s2) self.assertEqual(len(self.ctrl.getAll()), 2) self.ctrl.removeStudent(2) l = self.ctrl.getAll() self.assertEqual(l[0].getId(), 1) self.assertEqual(l[0].getName(), 'mark') def testUpdate(self): self.assertEqual(len(self.ctrl.getAll()), 0) s = Student(1, 'mark') self.ctrl.addStudent(s) self.assertEqual(len(self.ctrl.getAll()), 1) l = self.ctrl.getAll() self.assertEqual(l[0].getId(), 1) self.assertEqual(l[0].getName(), 'mark') self.ctrl.updateStudent(1, 'markk') l = self.ctrl.getAll() self.assertEqual(l[0].getId(), 1) self.assertEqual(l[0].getName(), 'markk')
gb = GradeBase() db = DisciplineBase() fgb = FileGradeBase() fsb = FileStudentBase() sb = StudentBase() db.add(Discipline("FPcurs")) db.add(Discipline("FPlab")) db.add(Discipline("FPseminar")) db.add(Discipline("Logica")) db.add(Discipline("ASC")) db.add(Discipline("Algebra")) db.add(Discipline("Analiza")) a = input("Press 1 for nonfile or 2 for file.") if int(a) == 2: undoCtrl = UndoController() sc = StudentController(fsb, undoCtrl) gc = GradeController(fgb, undoCtrl) dc = DisciplineController(db) sts = StatisticsController(gc, sc, dc) ui = UI(gc, sc, dc, undoCtrl, sts) ui.mainMenu() elif int(a) == 1: sb.add(Student(1, "Darius")) sb.add(Student(2, "Paul")) sb.add(Student(3, "Mark")) gb.add(Grade("FPcurs", 1, "arthur", 10)) gb.add(Grade("FPseminar", 2, "iuliana", 10)) gb.add(Grade("FPlab", 3, "arthur", 10))
from Domain import Student, Grades from Repository import StudentRepo, GradeRepo from Controller import StudentController, GradeController from Ui import Console # Create the repositories studentRepo = StudentRepo('students', Student.write_student, Student.read_student) gradeRepo = GradeRepo('grades', Grades.write_grades, Grades.read_grades) # Create the controllers studenController = StudentController(studentRepo) gradeController = GradeController(gradeRepo, studentRepo) # Create the console console = Console(studenController, gradeController) console.run()
def setUp(self): repo=StudentBase() undo=UndoController() self.ctrl=StudentController(repo,undo)
class Test(unittest.TestCase): def setUp(self): repo=StudentBase() undo=UndoController() self.ctrl=StudentController(repo,undo) def testAdd(self): self.assertEqual(len(self.ctrl.getAll()), 0) s=Student(1,'mark') self.ctrl.addStudent(s) self.assertEqual(len(self.ctrl.getAll()), 1) l=self.ctrl.getAll() self.assertEqual(l[0].getId(), 1) self.assertEqual(l[0].getName(), 'mark') def testFindById(self): self.assertEqual(len(self.ctrl.getAll()), 0) s=Student(1,'mark') self.ctrl.addStudent(s) s2=self.ctrl.findById(1) self.assertEqual(len(self.ctrl.getAll()), 1) l=self.ctrl.getAll() self.assertEqual(s.getId(), s2.getId()) self.assertEqual(s.getName(), s2.getName()) def testRemove(self): self.assertEqual(len(self.ctrl.getAll()), 0) s=Student(1,'mark') self.ctrl.addStudent(s) self.assertEqual(len(self.ctrl.getAll()), 1) l=self.ctrl.getAll() self.assertEqual(l[0].getId(), 1) self.assertEqual(l[0].getName(), 'mark') s2=Student(2,'ana') self.ctrl.addStudent(s2) self.assertEqual(len(self.ctrl.getAll()), 2) self.ctrl.removeStudent(2) l=self.ctrl.getAll() self.assertEqual(l[0].getId(), 1) self.assertEqual(l[0].getName(), 'mark') def testUpdate(self): self.assertEqual(len(self.ctrl.getAll()), 0) s=Student(1,'mark') self.ctrl.addStudent(s) self.assertEqual(len(self.ctrl.getAll()), 1) l=self.ctrl.getAll() self.assertEqual(l[0].getId(), 1) self.assertEqual(l[0].getName(), 'mark') self.ctrl.updateStudent(1, 'markk') l=self.ctrl.getAll() self.assertEqual(l[0].getId(), 1) self.assertEqual(l[0].getName(), 'markk')