def process(self, page_content=None, title='', response=None): request = self.factory.get('/', HTTP_X_PJAX=True) if not response: assert page_content is not None, ( 'Without a response, page_content= cannot be None') response = self.view(request, page_content, title=title) return LazyPjaxMiddleware().process_response(request, response)
def test_non_200_response(self): request = self.factory.get('/', HTTP_X_PJAX=True) response = http.HttpResponse('<html><body>Error</body></html>', status=500) response = LazyPjaxMiddleware().process_response(request, response) assert response.content.startswith('<html>'), ( 'Did not expect a pjax response: %s' % response.content)
def test_missing_page_element_logged_in_prod(self): request = self.factory.get('/', HTTP_X_PJAX=True) body = '<html><body></body></html>' response = http.HttpResponse(body) response = LazyPjaxMiddleware().process_response(request, response) eq_(response.content, body)
def test_missing_page_element(self): request = self.factory.get('/', HTTP_X_PJAX=True) response = http.HttpResponse('<html><body></body></html>') LazyPjaxMiddleware().process_response(request, response)