def test_post_creation(self):
        u = User(
            email=self.app.config['FLASKY_ADMIN'],
            password='testpass',
            name='Admin'
        )
        tag = Tag(name='node.js')
        cat = Category(name='node.js')
        db.session.add(u)
        db.session.add(tag)
        db.session.add(cat)
        db.session.commit()
        post = Post(
            author=u,
            title='Test Post',
            content='# Hello',
            tags=[tag],
            categories=[cat]
        )
        self.assertTrue(post.id is None)
        db.session.add(post)
        db.session.commit()
        self.assertTrue(post.id > 0)
        self.assertTrue(tag.posts.first().id == post.id)
        self.assertTrue(cat.posts.first().id == post.id)
        self.assertTrue(post.tags[0].id == tag.id)
        self.assertTrue(post.categories[0].id == cat.id)
dataset/ETHPy150Open brijeshb42/yapper/tests/PostTest/test_add_tag.py/TagAddTestCase.test_post_creation/original