def delete(self, studentID, eList, gList, name): studentID = int(studentID) redo = FunctionCall(self.removeStudent, studentID) undo = FunctionCall(self.addStudent, student(studentID, name)) operation = Operation(redo, undo) self._undoController.newOperation() self._undoController.recordOperation(operation) for Grade in gList: redo = FunctionCall(self._gCTRL.removeGradeList, Grade) undo = FunctionCall(self._gCTRL.addGradeList, Grade) operation = Operation(redo, undo) self._undoController.recordOperation(operation) for Enroll in eList: redo = FunctionCall(self._eCTRL.removeEnrollStudent, studentID) undo = FunctionCall(self._eCTRL.addEnroll, Enroll) operation = Operation(redo, undo) self._undoController.recordOperation(operation)
def add_Student(self): try: top = tk.Toplevel() top.title('Input') Input = Window2('Enter student ID: ', 'Enter student Name: ', top) Input.mainloop() top.destroy() if not Input.getvar(str( Input.Input1)) == None and not Input.getvar( str(Input.Input2)) == None: studentID = Input.getvar(str(Input.Input1)) name = Input.getvar(str(Input.Input2)) print studentID print name Valid().ID(studentID) Valid().name(name) self._studentControl.getCurentRepo().addStudent( student(int(studentID), name)) self._studentControl.create(int(studentID), name) self.refreshALL() except ValueError: self.displayError('Invalid Input') except NameError: self.displayError('Invalid Name') except idError: self.displayError('Invalid ID')
def create(self, studentID, name): redo = FunctionCall(self.addStudent, student(studentID, name)) undo = FunctionCall(self.removeStudent, studentID) operation = Operation(redo, undo) self._undoController.newOperation() self._undoController.recordOperation(operation)
def readRepo(self): with open( 'C:\Users\user\Desktop\Uni\FP\Eclipse\Lab 5-7 Propper\Initializers\students', 'r') as sFile: for line in sFile: self._list.append( student(int(line.split(' ', 1)[0]), line.split(' ', 1)[1][:-1]))
def testRepository(): repo = Repository() assert (len(repo) == 0) st1 = student("1", "Ioan Bogdan") repo.store(st1) assert (len(repo) == 1) st2 = student("2", "Alexandru Ivanov") repo + st2 assert (len(repo) == 2) st3 = student("2", "Fulea Razvan") try: repo.store(st3) assert False except RepositoryError: pass repo - st1 st2 - repo assert (len(repo) == 0)
def createStudent(self,ident,nume): ''' Stocheaza un student in catalog: student(id,nume) ''' st=student(ident,nume) self.__validator.valid(st) self.__repo.store(st) return st
def testClasses(self): ''' Function for the class tests ''' ''' :Student: :Section: ''' sTest = student(-1, 'Test') assert sTest.getId() == -1 assert sTest.getName() == 'Test' sTest.setId(int(-2)) assert sTest.getId() == -2 sTest.setName('Test2') assert sTest.getName() == 'Test2' ''' :Discipline: :Section: ''' dTest = discipline(-1, 'Test') assert dTest.getId() == -1 assert dTest.getName() == 'Test' dTest.setId(int(-2)) assert dTest.getId() == -2 dTest.setName('Test2') assert dTest.getName() == 'Test2' ''' :Enroll: :Section: ''' eTest = enroll(1, 1) assert eTest.get_discipline_id() == 1 assert eTest.get_student_id() == 1 eTest.set_discipline_id(2) assert eTest.get_discipline_id() == 2 eTest.set_student_id(2) assert eTest.get_student_id() == 2 ''' :Grade: :Section: ''' gTest = grade(1, 1) assert gTest.getDisciplineID() == 1 assert gTest.getStudentID() == 1 gTest.addGrade(10) assert gTest.getGrade() == [10] assert gTest.getGradeSize() == 1 gTest.setDisciplieID(2) assert gTest.getDisciplineID() == 2 gTest.setStudentID(int(-2))
def add_Student(self): studentID = int(input('\nEnter student ID: ')) name = str(raw_input('Enter student Name: ')) Valid().name(name) Valid().ID(studentID) S = self._studentControl D = self._disciplineControl E = self._enrolControl G = self._gradeControl self.addRepo(S,D,E,G) self._studentControl.addStudent(student(studentID,name)) print '\nStudent has been added' self.oCont += 1 self.compare()
def readRepo(self): with open(self._path, 'r') as sFile: for line in sFile: self._students.append( student(int(line.split(' ', 1)[0]), line.split(' ', 1)[1][:-1]))
def NewFile(self): self._studentControl.setRepo(deepcopy(student(1, ''))) self._disciplineControl.setRepo(deepcopy(discipline(1, ''))) self._enrolControl.setRepo(deepcopy(enroll(1, 1))) self._gradeControl.setRepo(deepcopy(grade(1, 1))) self.refreshALL()
def __init__(self): self._students = [student(1, 'Stefania Matei')]
def testRepos(self): ''' Function for the repository test ''' ''' :Student: :Section: ''' sTest = studentRepository() sTest.setStudents([]) assert sTest.getStudents() == [] assert sTest.getStudentSize() == 0 sTest.addStudent(student(1, 'Test')) assert sTest.getStudents() == [student(1, 'Test')] assert sTest.searchStudent(1) == student(1, 'Test') sTest.updateStudentID(1, 2) assert sTest.getStudents()[0].getId() == 2 sTest.updateStudentName(2, 'Test2') assert sTest.getStudents()[0].getName() == 'Test2' sTest.removeStudent(2) assert sTest.getStudents() == [] ''' :Discipline: :Section: ''' dTest = disciplineRepository() dTest.setDisciplines([]) assert dTest.getDisciplines() == [] assert dTest.getDisciplinesSize() == 0 dTest.addDiscipline(discipline(1, 'Test')) assert dTest.getDisciplines() == [discipline(1, 'Test')] assert dTest.searchDiscipline(1) == discipline(1, 'Test') dTest.updateDisciplineID(1, 2) assert dTest.getDisciplines()[0].getId() == 2 dTest.updateDisciplineName(2, 'Test2') assert dTest.getDisciplines()[0].getName() == 'Test2' dTest.removeDiscipline(2) assert dTest.getDisciplines() == [] ''' :Enroll: :Section: ''' eTest = enrollRepository() eTest.setEnroll([]) assert eTest.getEnroll() == [] assert eTest.getEnrollSize() == 0 en = enroll(1, 1) eTest.addEnrolment(en) assert eTest.getEnrollSize() == 1 assert eTest.getEnroll() == [en] assert eTest.searchEnrolment(en) == en eTest.addEnrolment(enroll(1, 2)) eTest.addEnrolment(enroll(2, 3)) eTest.removeEnrollDiscipline(2) eTest.removeEnrollStudent(2) assert eTest.getEnrollSize() == 1 ''' :Grade: :Section: ''' gTest = gradeRepository() gTest.setGrade([]) assert gTest.getGradesSize() == 0 assert gTest.getGrades() == [] gr = grade(1, 1) gTest.addGrade(gr, 10) assert gTest.getGrades() == [gr] assert gTest.getGrades()[0].getGrade() == [10.0] gTest.updateGradeDisciplineID(1, 2) assert gTest.getGrades()[0].getDisciplineID() == 2 gTest.updateGradeStudentID(1, 10) assert gTest.getGrades()[0].getStudentID() == 10 gTest.removeGradeDiscipline(2) assert gTest.getGradesSize() == 0 gr = grade(1, 1) gTest.addGrade(gr, 10) gr1 = grade(10, 1) gTest.addGrade(gr1, 10) assert gTest.getGradesSize() == 2 assert gTest.getGrades() == [gr, gr1] gr2 = grade(1, 10) gTest.addGrade(gr2, 10) assert gTest.getGrades() == [gr, gr1, gr2] gTest.removeGradeDiscipline(10) assert gTest.getGrades() == [gr, gr2] gTest.removeGradeStudent(10) assert gTest.getGrades() == [gr]
def setUp(self): self.__repo = Repository() self.__entity = student(1, "Bogdan")
def createMemoryControllers(self): sRepo = studentRepository() sRepo.addStudent(student(2, 'Ion Pascu')) sRepo.addStudent(student(3, 'Anrei Istoc')) sRepo.addStudent(student(4, 'Maria Jiu')) sRepo.addStudent(student(5, 'Camelia Danu')) sRepo.addStudent(student(6, 'Ionut Frunza')) sRepo.addStudent(student(7, 'Eleanor Popescu')) sRepo.addStudent(student(8, 'Ana-Maria Biju')) sRepo.addStudent(student(9, 'Dan Lautar')) sRepo.addStudent(student(10, 'Maria Babos')) sRepo.addStudent(student(11, 'Irina Mase')) sRepo.addStudent(student(12, 'Estera Chelariu')) sRepo.addStudent(student(13, 'Florin Andreescu')) sRepo.addStudent(student(14, 'Bobes Bogdan')) sRepo.addStudent(student(15, 'Victor Paul')) dRepo = disciplineRepository() dRepo.addDiscipline(discipline(2, 'Analiza Lexicografica')) dRepo.addDiscipline(discipline(3, 'Sport')) eRepo = enrollRepository() eRepo.addEnrolment(enroll(2, 1)) eRepo.addEnrolment(enroll(3, 1)) eRepo.addEnrolment(enroll(4, 1)) eRepo.addEnrolment(enroll(5, 1)) eRepo.addEnrolment(enroll(6, 2)) eRepo.addEnrolment(enroll(7, 2)) eRepo.addEnrolment(enroll(8, 2)) eRepo.addEnrolment(enroll(9, 2)) eRepo.addEnrolment(enroll(10, 2)) eRepo.addEnrolment(enroll(11, 3)) eRepo.addEnrolment(enroll(12, 3)) eRepo.addEnrolment(enroll(13, 3)) eRepo.addEnrolment(enroll(14, 3)) eRepo.addEnrolment(enroll(15, 3)) gRepo = gradeRepository() gRepo.addGrade(grade(1, 1), 10) gRepo.addGrade(grade(1, 2), 6.5) gRepo.addGrade(grade(1, 3), 4.3) gRepo.addGrade(grade(1, 4), 2.3) gRepo.addGrade(grade(1, 5), 6) gRepo.addGrade(grade(2, 6), 7) gRepo.addGrade(grade(2, 7), 7) gRepo.addGrade(grade(2, 8), 7) gRepo.addGrade(grade(2, 9), 7) gRepo.addGrade(grade(2, 10), 7) gRepo.addGrade(grade(3, 11), 7) gRepo.addGrade(grade(3, 12), 7) gRepo.addGrade(grade(3, 13), 7) gRepo.addGrade(grade(3, 14), 7) gRepo.addGrade(grade(3, 15), 7) E = enrollControllerWithUndo(eRepo, self._undoController) G = gradeControllerWithUndo(gRepo, self._undoController) S = studentControlWithUndo(sRepo, E, G, self._undoController) D = disciplineControlWithUndo(dRepo, E, G, self._undoController) return [S, D, E, G]
def setUp(self): self.__repo = FileRepository( "C:\\Users\\bogda\\Desktop\\pyth\\catalog_student\\Students.txt", student.readStudent, student.writeStudent) self.__entity = student(101, "Bogdan")