def test_displays_text(self): create_user() create_topic() post = create_post() response = self.client.get(reverse('posts:detail',args=(post.slug,))) self.assertEqual(response.status_code, 200) self.assertContains(response, post.title)
def test_with_posts(self): create_user() create_topic() post = create_post() response = self.client.get(reverse('posts:index')) self.assertEqual(response.status_code, 200) self.assertContains(response, post.title)
def test_user_active_comments_on_multiple_topic(self): this_user = create_user() first_topic = create_topic() first_post = create_post() first_comment = create_comment(first_post, this_user, text='FirstText') second_topic = create_topic(name='Something else') second_post = create_post(title='Different one') second_post.topic = second_topic second_comment = create_comment(second_post, this_user, text='SecondText') response = self.client.get(reverse('users:comments', args=(this_user.pk,))) self.assertContains(response, first_comment.text) self.assertContains(response, second_comment.text)
def test_user_profile_shows_comments(self): this_user = create_user() topic = create_topic() post = create_post() comment = create_comment(post, this_user) response = self.client.get(reverse('users:profile', args=(this_user.pk,))) self.assertContains(response, comment.text)
def test_topic_with_posts(self): topic = create_topic() some_user = create_user() post = create_post() response = self.client.get( reverse('topics:list_of_posts', args=(topic.slug, ))) self.assertContains(response, post.title)
def test_user_comments_not_active(self): this_user = create_user() topic = create_topic() post = create_post() comment = create_comment(post, this_user, active = False) response = self.client.get(reverse('users:comments', args=(this_user.pk,))) self.assertEquals(response.status_code, 200) self.assertNotContains(response, 'SomeComment')
def test_no_posts(self): topic = create_topic() response = self.client.get( reverse('topics:list_of_posts', args=(topic.slug, ))) self.assertContains(response, 'No posts yet in this topic.')
def test_valid_topic(self): topic = create_topic() response = self.client.get( reverse('topics:detail', args=(topic.slug, ))) self.assertContains(response, topic.details)
def test_with_topics(self): topic = create_topic() response = self.client.get(reverse('topics:index')) self.assertContains(response, topic.name)