Example #1
0
 def setUp(self):
     self.site = factories.make_world()
     self.admin_site = AdminSite()
     self.admin = DeferredMessageAdmin(DeferredMessage, self.admin_site)
     self.factory = RequestFactory()
     self.user = User.objects.get(username='******')
     self.user.is_superuser = True
Example #2
0
class RedeliverAdminActionTest(TestCase):
    def setUp(self):
        self.site = factories.make_world()
        self.admin_site = AdminSite()
        self.admin = DeferredMessageAdmin(DeferredMessage, self.admin_site)
        self.factory = RequestFactory()
        self.user = User.objects.get(username='******')
        self.user.is_superuser = True

    def test_redeliver(self):
        foireq = FoiRequest.objects.all()[0]
        dm = factories.DeferredMessageFactory()
        dm.save()
        req = self.factory.post('/', {})
        req.user = self.user

        result = self.admin.redeliver(
            req, DeferredMessage.objects.filter(id__in=[dm.id]))
        self.assertEqual(result.status_code, 200)

        req = self.factory.post('/', {'req_id': foireq.id})
        req.user = self.user
        req._messages = default_storage(req)

        result = self.admin.redeliver(
            req, DeferredMessage.objects.filter(id__in=[dm.id]))
        self.assertIsNone(result)

        dm = DeferredMessage.objects.get(id=dm.id)
        self.assertEqual(dm.request, foireq)
class RedeliverAdminActionTest(TestCase):
    def setUp(self):
        self.site = factories.make_world()
        self.admin_site = AdminSite()
        self.admin = DeferredMessageAdmin(DeferredMessage,
            self.admin_site)
        self.factory = RequestFactory()
        self.user = User.objects.get(username='******')
        self.user.is_superuser = True

    def test_redeliver(self):
        foireq = FoiRequest.objects.all()[0]
        dm = factories.DeferredMessageFactory()
        dm.save()
        req = self.factory.post('/', {})
        req.user = self.user

        result = self.admin.redeliver(req,
                DeferredMessage.objects.filter(
                    id__in=[dm.id]))
        self.assertEqual(result.status_code, 200)

        req = self.factory.post('/', {
            'req_id': foireq.id
        })
        req.user = self.user
        req._messages = default_storage(req)

        result = self.admin.redeliver(req,
                DeferredMessage.objects.filter(
                    id__in=[dm.id]))
        self.assertIsNone(result)

        dm = DeferredMessage.objects.get(id=dm.id)
        self.assertEqual(dm.request, foireq)
 def setUp(self):
     self.site = factories.make_world()
     self.admin_site = AdminSite()
     self.admin = DeferredMessageAdmin(DeferredMessage,
         self.admin_site)
     self.factory = RequestFactory()
     self.user = User.objects.get(username='******')
     self.user.is_superuser = True