Ejemplo n.º 1
0
 def check_http_method(method, klass):
     """Check HTTP functions"""
     request = getattr(self.request_factory, method)('/')
     request = patch_message_middleware(request)
     request.user = self.staff_user
     result = views.thread_unsubscribe_view(request, self.thread1.pk)
     self.assertIsInstance(result, klass)
Ejemplo n.º 2
0
    def test_thread_unsubscribe(self):
        """View should unsubscribe a user from a thread"""
        request = self.request_factory.post('/')
        request = patch_message_middleware(request)
        request.user = self.user1
        group = mommy.make('groups.Group')
        self.user1.add_to_group(group.pk)

        thread = mommy.make(Thread, group=group)
        mommy.make(Message, thread=thread, sender=self.user1)

        self.assertTrue(
            UserThread.objects.filter(user=self.user1,
                                      thread=thread,
                                      subscribed_email=True).exists())

        views.thread_unsubscribe_view(request, thread.pk)

        self.assertFalse(
            UserThread.objects.filter(user=self.user1,
                                      thread=thread,
                                      subscribed_email=True).exists())