예제 #1
0
 def test_message_flag_view(self):
     """view should flag a message and return the expected response."""
     request = self.request_factory.post('/')
     request.user = self.superuser
     message = self.message()
     message.status = 'approved'
     message.save()
     flag_count = message.flags.count()
     result = views.message_flag_view(request, message.pk)
     message = Message.objects.get(pk=message.pk)
     self.assertEqual(message.flags.count(), flag_count + 1)
     json_result = json.loads(result.content)
     self.assertTrue(json_result['success'])
     self.assertEqual(json_result['message_id'], message.pk)
예제 #2
0
 def check_http_method(method, klass):
     """Check HTTP functions"""
     request = getattr(self.request_factory, method)('/')
     request.user = self.staff_user
     result = views.message_flag_view(request, self.message1.pk)
     self.assertIsInstance(result, klass)