示例#1
0
 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)
示例#2
0
 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)
示例#3
0
    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)
示例#4
0
 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)
示例#5
0
 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)
示例#6
0
 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')
示例#7
0
 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.')
示例#8
0
 def test_valid_topic(self):
     topic = create_topic()
     response = self.client.get(
         reverse('topics:detail', args=(topic.slug, )))
     self.assertContains(response, topic.details)
示例#9
0
 def test_with_topics(self):
     topic = create_topic()
     response = self.client.get(reverse('topics:index'))
     self.assertContains(response, topic.name)