class ImageTestCase(TestCase): #Test that images are shown def setUp(self): self.thread = ThreadFactory() self.post = UserPostFactory() def test_thread_image_shown(self): resp = self.client.get(self.thread.board.get_absolute_url()) self.assertContains(resp, self.thread.image.url) def test_post_image_shown(self): resp = self.client.get(self.post.get_absolute_url()) self.assertContains(resp, self.post.image.url) def test_image_in_catalog(self): resp = self.client.get(self.thread.board.get_catalog_url()) self.assertContains(resp, self.thread.image.url)
class UserPostReportTestCase(TestCase): def setUp(self): self.post = UserPostFactory() self.get_resp = self.client.get(self.post.get_report_url()) self.post_resp = self.client.post(self.post.get_report_url()) self.post.refresh_from_db() def test_template_used(self): self.assertTemplateUsed(self.get_resp, 'imageboard/userpost_report_confirm.html') def test_context(self): self.assertTrue('userpost' in self.get_resp.context) def test_context_correct(self): self.assertEqual(self.get_resp.context['userpost'], self.post) def test_redirect(self): self.assertRedirects(self.post_resp, expected_url=self.post.get_absolute_url(), status_code=302) def test_thread_reported(self): self.assertTrue(self.post.reported)