예제 #1
0
    def test_all_correct(self):
        self.environment.database.create_account("testuser", "1234", "supervisor")
        login = Login(self.environment)
        response = login.action(["login", "testuser", "1234"])

        self.assertEqual(response, "Logged in.")
        self.assertIsNotNone(self.environment.user)
예제 #2
0
    def test_wrong_both(self):
        self.environment.database.create_account("testuser", "1234", "supervisor")
        login = Login(self.environment)
        response = login.action(["login", "testuse", "123"])

        self.assertEqual(response, "Error logging in.")
        self.assertIsNone(self.environment.user)
예제 #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(["login", "testuser", "1234"])

        self.assertEqual(response, "Error logging in.")
        self.assertIsNotNone(self.environment.user)
예제 #4
0
    def test_too_many_args(self):
        login = Login(self.environment)
        response = login.action(["login", "testuser", "1234", "foo"])

        self.assertEqual(response, "Error logging in.")
        self.assertIsNone(self.environment.user)
예제 #5
0
    def test_not_enough_args(self):
        login = Login(self.environment)
        response = login.action(["login", "testuser"])

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