def test_comment_content_renders_on_posts_view(self): """Test comment comntent is in post request.""" this_user = self.users[0] self.client.force_login(this_user) this_post = Post() this_post.author = this_user this_post.content = 'tornado fire crocodile' this_post.title = 'marc ben benny built this site' this_post.save() this_comment = Comment() this_comment.by_user = this_user this_comment.on_post = this_post this_comment.comment = 'this comment' this_comment.save() response = self.client.post( '/posts/' + str(this_post.id), follow=True) self.assertContains(response, 'this comment')
def test_comment_model_returns_string(self): """Test the post model has string function.""" instance = Comment() instance.comment = 'comment' assert str(instance) == 'comment'