def test_report_view_notloggedin(self): need = AN_UNSAVED_NEED() need.save() response = self.client.post(reverse('moderation_report', args=[], kwargs={'app_label': need._meta.app_label, 'model_name': need._meta.module_name, 'obj_id': need.id}), {'reason': Report.SPAM, 'comment': 'Testing'}) content = simplejson.loads(response.content) self.assertEqual(content['success'], 'false')
def test_create_report(self): """You need to set ADMINS on your settings file for this test""" user = self.login_user(username='******') need = AN_UNSAVED_NEED() need.save() moderation = Moderation.objects.get_for_object(need) self.assertFalse(moderation) report = create_report(obj=need, user=user, reason=Report.ANOTHER, comment='Testing') moderation = Moderation.objects.get_for_object(need)[0] self.assertEqual(moderation.reports.count(), 1) self.assertQuerysetEqual(moderation.reports.filter(user=user), map(repr, [report])) self.assertEqual(len(mail.outbox), 1)
def AN_UNSAVED_PROPOSAL(): need = AN_UNSAVED_NEED() need.save() return Proposal(title="Resolver", description="lorem ipsum", need=need)
def setUp(self): self.need = AN_UNSAVED_NEED()