Ejemplo n.º 1
0
    def test_all_correct(self):
        self.environment.database.create_account("testuser", "1234",
                                                 "supervisor")
        login = Login(self.environment)
        response = login.action({"username": "******", "password": "******"})

        self.assertEqual(response, "Logged in.")
        self.assertIsNotNone(self.environment.user)
Ejemplo n.º 2
0
    def test_wrong_both(self):
        self.environment.database.create_account("testuser", "1234",
                                                 "supervisor")
        login = Login(self.environment)
        response = login.action({"username": "******", "password": "******"})

        self.assertEqual(response, "Error logging in.")
        self.assertIsNone(self.environment.user)
Ejemplo n.º 3
0
    def test_already_logged_in(self):
        self.environment.user = User("someone_else", "supervisor")

        self.environment.database.create_account("testuser", "1234",
                                                 "supervisor")
        login = Login(self.environment)
        response = login.action({"username": "******", "password": "******"})

        self.assertEqual(response, "Error logging in.")
        self.assertIsNotNone(self.environment.user)
Ejemplo n.º 4
0
 def __init__(self, environment):
     self.environment = environment
     self.commands = {
         "login": Login.Login(self.environment),
         "logout": Login.Logout(self.environment),
         "create_account": AccountCommands.CreateAccount(self.environment),
         "delete_account": AccountCommands.DeleteAccount(self.environment),
         "view_accounts": AccountCommands.ViewAccounts(self.environment),
         "view_info": AccountCommands.ViewInfo(self.environment),
         "create_course": CourseCommands.CreateCourse(self.environment),
         "assign_course": CourseCommands.AssignCourse(self.environment),
         "view_courses": CourseCommands.ViewCourses(self.environment),
         "create_lab": LabCommands.CreateLab(self.environment),
         "assign_lab": LabCommands.AssignLab(self.environment),
         "view_labs": LabCommands.ViewLabs(self.environment),
         "edit_info": EditInfo.EditInfo(self.environment),
         "update_info": UpdateInfo.EditInfo(self.environment)
     }
Ejemplo n.º 5
0
    def test_too_many_args(self):
        login = Login(self.environment)
        response = login.action({"username": "******", "password": "******"})

        self.assertEqual(response, "Error logging in.")
        self.assertIsNone(self.environment.user)
Ejemplo n.º 6
0
    def test_not_enough_args(self):
        login = Login(self.environment)
        response = login.action({"username": "******", "password": None})

        self.assertEqual(response, "Error logging in.")
        self.assertIsNone(self.environment.user)