Exemple #1
0
 def uiUpdateStud(self):
     cmd = input(
         "To update a student specific info type 1\n or 0 for complete infos:"
     ).strip()
     s = Student(-1, -1, -1)
     if cmd == '1':
         info = input("To modify: Name type 1, Group type 2: ").strip()
         if info == '1':
             s.id = int(input("Students ID you want to update: "))
             s.name = input("Enter new name: ")
             s.group = self._stud.findByID(s.id).group
             StudentValidator().validate(s)
             self._stud.update(s)
             return True
         elif info == '2':
             s.id = int(input("Students ID you want to update: "))
             s.group = input("Enter new grop: ")
             s.name = self._stud.findByID(s.id).name
             StudentValidator().validate(s)
             self._stud.update(s)
             return True
         else:
             print("Invalid command!")
     elif cmd == '0':
         s.id = int(input("Students ID you want to update: "))
         s.name = input("Enter new name: ")
         s.group = input("Enter new grop: ")
         StudentValidator().validate(s)
         self._stud.update(s)
         return True
     else:
         print("Invalid command!")
 def setUp(self):
     self.undo = UndoController()
     self.stCtr = StudentController(Repository(), StudentValidator(),
                                    self.undo)
     self.asCtr = AssignmnetController(Repository(), AssignmentValidator(),
                                       self.undo)
     self.grade = Grade(1, 1, 5.0)
     self._grCtr = GradeController(Repository(), GradeValidator(),
                                   self.stCtr, self.asCtr, self.undo)
Exemple #3
0
 def __init__(self):
     self._undo = UndoController()
     self._stud = StudentController(Repository(), StudentValidator(),
                                    self._undo)
     self._assign = AssignmnetController(Repository(),
                                         AssignmentValidator(), self._undo)
     self._grade = GradeController(Repository(), GradeValidator(),
                                   self._stud, self._assign, self._undo)
     self._stat = Statistics(self._grade)
Exemple #4
0
 def setUp(self):
     self._undo = UndoController()
     self._stCtr = StudentController(Repository(), StudentValidator(),
                                     self._undo)
     self._asCtr = AssignmnetController(Repository(), AssignmentValidator(),
                                        self._undo)
     self._grCtr = GradeController(Repository(), GradeValidator(),
                                   self._stCtr, self._asCtr, self._undo)
     self._stat = Statistics(self._grCtr)
     populateAsCtrSTATIC(self._asCtr)
     populateStCtrSTATIC(self._stCtr)
class UnitTestStudent(unittest.TestCase):
    '''
        Provides Unittests for Student Domain
    '''
    def setUp(self):
        self.v = StudentValidator()
        self.s = Student(1, "Matei", "913")

    def tearDown(self):
        unittest.TestCase.tearDown(self)
        self.s = None
        self.v = None

    def testID(self):
        self.s.id = -5
        self.assertRaises(ValidatorException, self.v.validate, self.s)
        self.s.id = 0
        self.assertRaises(ValidatorException, self.v.validate, self.s)
        self.s.id = None
        self.assertRaises(ValidatorException, self.v.validate, self.s)
        self.s.id = "1"
        self.assertRaises(ValidatorException, self.v.validate, self.s)
        self.s.id = 1
        self.assertEqual(self.v.validate(self.s), True)
        self.assertTrue(self.s <= Student(2, "zoro", "913"))
        self.assertTrue(str(self.s))
        self.assertTrue(repr(self.s))

    def testName(self):
        self.s.name = ""
        self.assertRaises(ValidatorException, self.v.validate, self.s)
        self.s.name = 3
        self.assertRaises(ValidatorException, self.v.validate, self.s)
        self.s.name = None
        self.assertRaises(ValidatorException, self.v.validate, self.s)

    def testGroup(self):
        self.s.group = ""
        self.assertRaises(ValidatorException, self.v.validate, self.s)
        self.s.group = 3
        self.assertRaises(ValidatorException, self.v.validate, self.s)
        self.s.group = None
        self.assertRaises(ValidatorException, self.v.validate, self.s)
Exemple #6
0
elif sets.repo == "binary_file":
    stRepo = BinRepository("data\\" + sets.repoSt, Student)
    asRepo = BinRepository("data\\" + sets.repoAs, Assignment)
    grRepo = BinRepository("data\\" + sets.repoGr, Grade)
elif sets.repo == "json_file":
    stRepo = JsonRepository("data\\" + sets.repoSt, Student)
    asRepo = JsonRepository("data\\" + sets.repoAs, Assignment)
    grRepo = JsonRepository("data\\" + sets.repoGr, Grade)
elif sets.repo == "mongoDB":
    stRepo = MongoRepository(Student)
    asRepo = MongoRepository(Assignment)
    grRepo = MongoRepository(Grade)
else:
    raise ValueError("Repo must be from memory/text_file/binary_file/json_file/mongoDB")

stCtr = StudentController(stRepo, StudentValidator(), undoCtr)
asCtr = AssignmnetController(asRepo, AssignmentValidator(), undoCtr)
grCtr = GradeController(grRepo, GradeValidator(), stCtr, asCtr, undoCtr)
stat = Statistics(grCtr)
if sets.ui == "cli":
    menu = CliMenu(undoCtr, stCtr, asCtr, grCtr, stat)
    menu.mainMenu()
elif sets.ui == "gui":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    StudentsManagement = QtWidgets.QMainWindow()
    ui = Ui_StudentsManagement(undoCtr, stCtr, asCtr, grCtr, stat)
    ui.setupUi(StudentsManagement)
    StudentsManagement.show()
    sys.exit(app.exec_())
 def setUp(self):
     self.v = StudentValidator()
     self.s = Student(1, "Matei", "913")
Exemple #8
0
 def setUp(self):
     self.s = Student(1, "John", "913")
     self.undo = UndoController()
     self.sCtr = StudentController(Repository(), StudentValidator(),
                                   self.undo)