Beispiel #1
0
 def mainMenu(self):
     '''
     This is where the user interacts with the rest of the program
     '''
     while 1:            
         try:
             Controller.setCommand(self._controller, input("Write a command (type help for a list): "))
         except ValueError:
             print("Invalid command parameter!")
             
         try:
             Controller.checkCommand(self._controller)
         except CommandNotFound:
             print ("Command not found!")
         except SystemExit:
             print ("Exiting program...")
             return True
Beispiel #2
0
 def _test_controller_checkCommand(self):
     '''
     Tests if all command are found
     '''
     
     controller = Controller("debug")
     
     try:
         controller.setCommand("yus")
         Controller.checkCommand(controller, 1)
         assert False
     except CommandNotFound:
         assert True
         
     try:
         controller.setCommand("exit")
         Controller.checkCommand(controller, 1)
         assert False
     except Debug:
         assert True
     except:
         assert False
     
     try:   
         controller.setCommand("help")
         Controller.checkCommand(controller, 1)
     except Debug:
         assert True
     except:
         assert False
     
     try:
         controller.setCommand("print students")
         Controller.checkCommand(controller, 1)
     except Debug:
         assert True
     except:
         assert False
     
     try:
         controller.setCommand("print grades")
         Controller.checkCommand(controller, 1)
     except Debug:
         assert True
     except:
         assert False
     
     try:
         controller.setCommand("print disciplines")
         Controller.checkCommand(controller, 1)
     except Debug:
         assert True
     except:
         assert False
     
     try:
         controller.setCommand("print all")
         Controller.checkCommand(controller, 1)
     except Debug:
         assert True
     except:
         assert False
         
     try:
         controller.setCommand("add discipline fp")
         Controller.checkCommand(controller, 1)
     except Debug:
         assert True
     except:
         assert False
         
     try:
         controller.setCommand("add student John")
         Controller.checkCommand(controller, 1)
     except Debug:
         assert True
     except:
         assert False
         
     try:
         controller.setCommand("add grade fp, 1, 7.5, Arthur")
         Controller.checkCommand(controller, 1)
     except Debug:
         assert True
     except:
         False