def test_delete(self, *args):
     """
     Test DELETE request.
     """
     response = auth.AuthAPI().delete()
     self.assertIsInstance(response, dict)
     self.assertFalse(response)
 def test_post(self, *args):
     """
     Test POST request.
     """
     response = auth.AuthAPI().post()
     self.assertIsInstance(response, dict)
     self.assertIn(constants.Auth.TOKEN, str(response))
 def test_put(self, *args):
     """
     Test PUT request.
     """
     response = auth.AuthAPI().put()
     self.assertIn(str(errors.MethodNotImplementedException.SUBCODE),
                   str(response))
 def test_delete_user_id(self, *args):
     """
     Test DELETE request with bad user ID.
     """
     with patch.object(auth.users.AuthController, "logout") as mock:
         mock.side_effect = auth.users.UserIDException
         response = auth.AuthAPI().delete()
         self.assertIn(str(errors.AuthException.SUBCODE), str(response))
 def test_unknown_error(self, *args):
     """
     Test POST request if user is not found.
     """
     with patch.object(auth.users.AuthController, "login") as mock:
         mock.side_effect = RuntimeError()
         response = auth.AuthAPI().post()
         self.assertIn(str(errors.MariaException.SUBCODE), str(response))
 def test_post_empty_username(self, *args):
     """
     Test POST request if username is empty.
     """
     with patch.object(auth.users.AuthController, "login") as mock:
         mock.side_effect = auth.users.UsernameException
         response = auth.AuthAPI().post()
         self.assertIn(str(errors.UsernameFormError.SUBCODE), str(response))
 def test_post_user_inactive(self, *args):
     """
     Test POST request if user is inactive.
     """
     with patch.object(auth.users.AuthController, "login") as mock:
         mock.side_effect = auth.users.InactiveUserException
         response = auth.AuthAPI().post()
         self.assertIn(str(errors.AuthException.SUBCODE), str(response))
 def test_delete_error(self, *args):
     """
     Test DELETE request if something goes wrong.
     """
     with patch.object(auth.users.AuthController, "logout") as mock:
         mock.side_effect = auth.users.AuthException
         response = auth.AuthAPI().delete()
         self.assertIn(str(errors.AuthException.SUBCODE), str(response))
 def test_delete_not_found(self, *args):
     """
     Test DELETE request if user is not found.
     """
     with patch.object(auth.users.AuthController, "logout") as mock:
         mock.side_effect = auth.users.UserNotFoundException
         response = auth.AuthAPI().delete()
         self.assertIn(str(errors.UserNotFoundAuthException.SUBCODE),
                       str(response))
Exemplo n.º 10
0
 def test_post_wrong_password(self, *args):
     """
     Test POST request if password is invalid.
     """
     with patch.object(auth.users.AuthController, "login") as mock:
         mock.side_effect = auth.users.WrongPasswordException
         response = auth.AuthAPI().post()
         self.assertIn(str(errors.InvalidPasswordAuthException.SUBCODE),
                       str(response))