def test_should_publish_a_post(self): CreationPost.create_draft( 'title', 'description', 'long text', 'author' ) post_db = Post.objects.first() CreationPost.publish(post_db.id) post_db = Post.objects.first() self.assertEqual(0, post_db.comments.count()) self.assertIsNotNone(post_db.published_on)
def test_should_add_a_comment_for_a_post(self): CreationPost.create_draft( 'title', 'description', 'long text', 'author' ) post_db = Post.objects.first() CreationPost.publish(post_db.id) CreationPost.add_comment( post_db, 'author of the comment', 'commentary' ) [comment_db] = CreationPost.get_comments_from_post(post_db.id) self.assertEqual('author of the comment', comment_db.author) self.assertEqual('commentary', comment_db.text)