コード例 #1
0
ファイル: tests.py プロジェクト: roselmamendes/blog-django
 def test_should_not_allow_save_a_comment_without_post_related(self):
     with self.assertRaises(Exception):
         CreationPost.add_comment(
             None,
             'author',
             'some text'
         )
コード例 #2
0
ファイル: tests.py プロジェクト: roselmamendes/blog-django
    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)