Ejemplo n.º 1
0
    def test_finalize_response(self):
        middleware = PersistMiddleware(self.get_response_mock)
        request = self.request_factory.post('/')
        request.persisted_query = PersistedQuery(None, {})

        response = middleware(request)
        data = parse_json(response.content)

        self.assertEqual(response.status_code, 200)
        self.assertTrue(data['test'])
    def test_versioning_not_allowed(self):
        middleware = PersistMiddleware(self.get_response_mock)

        request = self.factory.post(
            '?{0}={1}'.format(persist_settings.VERSION_PARAM, 'not-allowed'), )

        response = middleware(request)

        self.assertEqual(response.status_code, 400)
        self.assertIsInstance(response, exceptions.PersistResponseError)
Ejemplo n.º 3
0
 def setUp(self):
     self.request_factory = JSONRequestFactory()
     self.get_response_mock = Mock(return_value=JsonResponse({}))
     self.middleware = PersistMiddleware(self.get_response_mock)
     self.view_func = GraphQLView.as_view()