示例#1
0
 def uiUpdateAssig(self):
     cmd = input("To update an assignment specific info type 1\nor 2 for complete infos:").strip()
     assign = Assignment(-1, -1, -1)
     if cmd == '1':
         info = input("To modify: Description type 1, Deadline type 2: ").strip()
         if info == '1':
             assign.id = int(input("Assignments ID you want to update: "))
             newDesc = input("Enter new description: ")
             assign.description = newDesc
             assign.deadline = self._assign.findByID(assign.id).deadline
             AssignmentValidator().validate(assign)
             self._assign.update(assign)
             return True
         elif info == '2':
             assign.id = int(input("Assignments ID you want to update: "))
             newDeadline = input("Enter new deadline: ")
             assign.deadline = newDeadline
             assign.description = self._assign.findByID(assign.id).description
             AssignmentValidator().validate(assign)
             self._assign.update(assign)
             return True
         else:
             print("Invalid command!")
     elif cmd == '2':
         assign.id = int(input("Assignment ID you are looking to update: "))
         assign.description = input("Enter new description: ")
         assign.deadline = input("Enter new deadline: ")
         AssignmentValidator().validate(assign)
         self._assign.update(assign)
         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)
示例#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)
示例#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)
示例#5
0
class UnitTestAssignmnet(unittest.TestCase):
    '''
        Provides Unittests for Assignment domain
    '''

    def setUp(self):
        self.a = Assignment(1, "FP", "01/02/2019")
        self.v = AssignmentValidator()

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

    def testID(self):
        self.assertEqual(self.v.validate(self.a), True)
        self.a.id = 0
        self.assertRaises(ValidatorException, self.v.validate, self.a)
        self.a.id = -1
        self.assertRaises(ValidatorException, self.v.validate, self.a)
        self.a.id = "d"
        self.assertRaises(ValidatorException, self.v.validate, self.a)
        self.a.id = "1"
        self.assertRaises(ValidatorException, self.v.validate, self.a)

    def testDescription(self):
        self.a.description = ""
        self.assertRaises(ValidatorException, self.v.validate, self.a)
        self.a.description = 5
        self.assertRaises(ValidatorException, self.v.validate, self.a)

    def testDeadline(self):
        self.a.deadline = 5
        self.assertRaises(ValidatorException, self.v.validate, self.a)
        self.a.deadline = "-1/5/1000"
        self.assertRaises(ValidatorException, self.v.validate, self.a)
        self.a.deadline = "30/2/2000"
        self.assertRaises(ValidatorException, self.v.validate, self.a)
        self.a.deadline = "32/5/2000"
        self.assertRaises(ValidatorException, self.v.validate, self.a)
        self.a.deadline = "5/0/1200"
        self.assertRaises(ValidatorException, self.v.validate, self.a)
        self.a.deadline = "5/13/2010"
        self.assertRaises(ValidatorException, self.v.validate, self.a)
        self.assertTrue(str(self.a))
        self.assertTrue(repr(self.a))
示例#6
0
    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_())

else:
示例#7
0
 def setUp(self):
     self.a = Assignment(1, "FP", "01/02/2019")
     self.v = AssignmentValidator()
 def setUp(self):
     self.a = Assignment(1, "ASC", "08/12/2018")
     self.aCtr = AssignmnetController(Repository(), AssignmentValidator(),
                                      UndoController())