def test_noreplace(self): from c2cgeoportal_geoportal.lib.cacheversion import CachebusterTween registry = pyramid.registry.Registry() registry.settings = {"cache_path": ["test"]} ctf = CachebusterTween(handler, registry) request = MyRequest("/test2/123456/build.css") ctf(request) self.assertEqual(request.path_info, "/test2/123456/build.css")
def test_noreplace(self): from c2cgeoportal_geoportal.lib.cacheversion import CachebusterTween CACHE_PATH.append("test") ctf = CachebusterTween(handler, None) request = MyRequest("/test2/123456/build.css") response = ctf(request) self.assertEqual(request.path_info, "/test2/123456/build.css") # test no CORS self.assertNotIn("Access-Control-Allow-Origin", list(response.headers.keys())) self.assertNotIn("Access-Control-Allow-Headers", list(response.headers.keys()))
def test_replace(self): from c2cgeoportal_geoportal.lib.cacheversion import CachebusterTween CACHE_PATH.append("test") ctf = CachebusterTween(handler, None) request = MyRequest("/test/123456/build.css") response = ctf(request) self.assertEqual(request.path_info, "/test/build.css") # test CORS self.assertEqual(response.headers["Access-Control-Allow-Origin"], "*") self.assertEqual(response.headers["Access-Control-Allow-Headers"], "X-Requested-With, Content-Type")