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)
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)
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)
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) }
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)
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)