def test_get(self):
        pc = PostController()
        post_id = pc.create(1, 'hello world')
        post = pc.get(1, post_id)
        self.assertIsInstance(post, ttypes.Post)
        self.assertEqual(post_id, post.id)

        post_id = pc.create(1, 'hello world')
        post = pc.get(1, post_id)
        self.assertIsInstance(post, ttypes.Post)
        self.assertEqual(post_id, post.id)
        # self.assertTrue(pc.get())



    # def test_foo(self):
    #     self.fail()
Ejemplo n.º 2
0
    def post(self):
        data = Post.parser.parse_args()

        auth_header = request.headers.get('Authorization')
        if auth_header:
            access_token = auth_header.split(" ")[1]
        else:
            return {
                "message": "This method requires an authorization header."
            }, 400
        error, client_id = auth_by_token(access_token)
        if error:
            return {"message": error}, 401

        error_message = PostController.create_post(data['theme'],
                                                   data['anonymity'],
                                                   client_id, data['content'])
        if error_message:
            return {"message": error_message}, 400

        return {"message": "Success!"}, 201
Ejemplo n.º 3
0
 def get(self):
     return PostController.get(self)
Ejemplo n.º 4
0
 def post(self):
     return PostController.post(self)
    def test_create(self):
        pc = PostController()

        self.assertRaises(TypeError, pc.create, 'one', 'foo')
        self.assertEqual(1, pc.create(1, 'hello world'))
        self.assertEqual(2, pc.create(1, 'sample post'))