Exemplo n.º 1
0
    def test_delete_post_by_manager(self):
        args = {
            "user_id": 1,
            "post_id": 2
        }

        Post.delete_post(**args)
        post = DBPost.get_by_id(2)
        self.assertIsNone(post)
Exemplo n.º 2
0
    def test_delete_post_all_field_valid(self):
        args = {
            "user_id": 1,
            "post_id": 1
        }

        Post.delete_post(**args)
        post = DBPost.get_by_id(1)
        self.assertIsNone(post)
Exemplo n.º 3
0
    def test_delete_not_exist_post(self):
        args = {
            "user_id": 2,
            "post_id": 100
        }

        try:
            Post.delete_post(**args)
            self.fail("Expect PostNotFoundError")
        except PostNotFoundError:
            pass
Exemplo n.º 4
0
    def test_delete_post_without_permission(self):
        """
        user who want to delete pos is not the author or manager
        :return:
        """
        args = {
            "user_id": 2,
            "post_id": 3
        }

        try:
            Post.delete_post(**args)
            self.fail("Expect AccessDeniedError")
        except AccessDeniedError:
            pass