예제 #1
0
    def test_not_js(self):
        request = self.factory.get("/tinymce/compressor/")
        response = gzip_compressor(request)

        self.assertEqual(200, response.status_code)
        self.assertEqual("text/javascript", response["Content-Type"])
        self.assertContains(response, "tinyMCE_GZ")
예제 #2
0
    def test_not_js(self):
        request = self.factory.get('/tinymce/compressor/')
        response = gzip_compressor(request)

        self.assertEqual(200, response.status_code)
        self.assertEqual('text/javascript', response['Content-Type'])
        self.assertContains(response, 'tinyMCE_GZ')
예제 #3
0
    def test_not_js(self):
        request = self.factory.get('/tinymce/compressor/')
        response = gzip_compressor(request)

        self.assertEqual(200, response.status_code)
        self.assertEqual('text/javascript', response['Content-Type'])
        self.assertContains(response, 'tinyMCE_GZ')
예제 #4
0
    def test_cache_data_last_modified(self, cache_mock):
        cache_mock.return_value = {
            "Last-Modified": "test",
        }
        request = self.factory.get("/tinymce/compressor/", {"js": "true"})
        request.META["HTTP_IF_MODIFIED_SINCE"] = "test"
        response = gzip_compressor(request)

        self.assertEqual(304, response.status_code)
        self.assertEqual("0", response["Content-Length"])
        self.assertEqual("text/javascript", response["Content-Type"])
        self.assertEqual(b"", response.content)
        self.assertTrue(cache_mock.called_once)
예제 #5
0
 def test_compressor(self):
     request = self.factory.get('/tinymce/compressor/', {
         'js': 'true',
         'compress': 'true',
         'languages': 'en',
         'plugins': 'example',
         'themes': 'advanced',
     })
     response = gzip_compressor(request)
     response_string = zlib.decompress(response.content, 16 + zlib.MAX_WBITS)
     self.assertEqual(200, response.status_code)
     self.assertEqual('text/javascript', response['Content-Type'])
     self.assertEqual('gzip', response['Content-Encoding'])
     self.assertIn(b'var tinyMCEPreInit', response_string)
예제 #6
0
    def test_cache_data_last_modified(self, cache_mock):
        cache_mock.return_value = {
            'Last-Modified': 'test',
        }
        request = self.factory.get('/tinymce/compressor/', {
            'js': 'true',
        })
        request.META['HTTP_IF_MODIFIED_SINCE'] = 'test'
        response = gzip_compressor(request)

        self.assertEqual(304, response.status_code)
        self.assertEqual('0', response['Content-Length'])
        self.assertEqual('text/javascript', response['Content-Type'])
        self.assertEqual(b'', response.content)
        self.assertTrue(cache_mock.called_once)
예제 #7
0
    def test_cache_data_last_modified(self, cache_mock):
        cache_mock.return_value = {
            'Last-Modified': 'test',
        }
        request = self.factory.get('/tinymce/compressor/', {
            'js': 'true',
        })
        request.META['HTTP_IF_MODIFIED_SINCE'] = 'test'
        response = gzip_compressor(request)

        self.assertEqual(304, response.status_code)
        self.assertEqual('0', response['Content-Length'])
        self.assertEqual('text/javascript', response['Content-Type'])
        self.assertEqual(b'', response.content)
        self.assertTrue(cache_mock.called_once)
예제 #8
0
 def test_compressor(self):
     request = self.factory.get(
         "/tinymce/compressor/",
         {
             "js": "true",
             "compress": "true",
             "languages": "en",
             "plugins": "example",
             "themes": "advanced",
         },
     )
     response = gzip_compressor(request)
     response_string = zlib.decompress(response.content, 16 + zlib.MAX_WBITS)
     self.assertEqual(200, response.status_code)
     self.assertEqual("text/javascript", response["Content-Type"])
     self.assertEqual("gzip", response["Content-Encoding"])
     self.assertIn(b"var tinyMCEPreInit", response_string)
예제 #9
0
def compressor(request):
    """
    Returns a GZip-compressed response.
    """
    return gzip_compressor(request)
예제 #10
0
def compressor(request):
    """
    Returns a GZip-compressed response.
    """
    return gzip_compressor(request)