class UserPostReportDismissView(TestCase): def setUp(self): mod = ModeratorFactory.create_mod() self.client.force_login(mod) self.post = UserPostFactory(reported=True) self.resp_get = self.client.get(self.post.get_report_dismiss_url()) self.resp_post = self.client.post(self.post.get_report_dismiss_url()) def test_report_dismiss_view_works(self): self.assertEqual(self.resp_get.status_code, 200) def test_report_dismiss_template(self): self.assertTemplateUsed(self.resp_get, 'moderation/report_confirm_delete.html') def test_report_dimiss_context(self): self.assertEqual(self.resp_get.context['object'], self.post) def test_report_dismiss_contains(self): self.assertContains(self.resp_get, self.post.post_number) def test_report_dismiss_redirect(self): self.assertRedirects( self.resp_post, expected_url=reverse('dj-mod:moderation_userpost_report_list'), status_code=302) def test_report_dismissed(self): self.post.refresh_from_db() self.assertFalse(self.post.reported)
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)