def tearDown(self): settings.COMPRESS_ENABLED = self._old_compress settings.COMPRESS_OFFLINE = self._old_compress_offline settings.TEMPLATE_DIRS = self._old_template_dirs manifest_path = os.path.join('CACHE', 'manifest.json') if default_storage.exists(manifest_path): default_storage.delete(manifest_path)
def check_compressor(app_configs, **kwargs): errors = [] # Get all configs if we don't get a specific set if not app_configs: app_configs = apps.apps.app_configs.values() compressor_installed = bool( list(filter(lambda app: app.name == "compressor", app_configs))) if not compressor_installed: errors.append(W001) else: # Check if storage is writeable try: # noinspection PyPackageRequirements,PyUnresolvedReferences from compressor.storage import default_storage as storage path = storage.save('test', ContentFile('new content')) except ImportError: errors.append(E001) except IOError: errors.append(E002) else: storage.delete(path) if not getattr(settings, 'COMPRESS_ENABLED'): errors.append(E003) if getattr(settings, 'COMPRESS_DEBUG_TOGGLE'): errors.append(E004) return errors
def check_compressor(app_configs, **kwargs): errors = [] # Get all configs if we don't get a specific set if not app_configs: app_configs = apps.apps.app_configs.values() compressor_installed = bool(list(filter(lambda app: app.name == "compressor", app_configs))) if not compressor_installed: errors.append(W001) else: # Check if storage is writeable try: # noinspection PyPackageRequirements,PyUnresolvedReferences from compressor.storage import default_storage as storage path = storage.save('test', ContentFile('new content')) except ImportError: errors.append(E001) except IOError: errors.append(E002) else: storage.delete(path) if not getattr(settings, 'COMPRESS_ENABLED'): errors.append(E003) if getattr(settings, 'COMPRESS_DEBUG_TOGGLE'): errors.append(E004) return errors
def tearDown(self): settings.COMPRESS_JINJA2_GET_ENVIRONMENT = self._old_jinja2_get_environment settings.COMPRESS_ENABLED = self._old_compress settings.COMPRESS_OFFLINE = self._old_compress_offline settings.TEMPLATE_DIRS = self._old_template_dirs manifest_path = os.path.join('CACHE', 'manifest.json') if default_storage.exists(manifest_path): default_storage.delete(manifest_path)
def tearDown(self): settings.COMPRESS_ENABLED = self._old_compress settings.COMPRESS_OFFLINE = self._old_compress_offline settings.TEMPLATE_DIRS = self._old_template_dirs self.template_file.close() manifest_path = os.path.join('CACHE', 'manifest.json') if default_storage.exists(manifest_path): default_storage.delete(manifest_path)
def tearDown(self): settings.COMPRESS_ENABLED = self._old_compress settings.COMPRESS_OFFLINE = self._old_compress_offline settings.TEMPLATE_DIRS = self._old_template_dirs settings.TEMPLATE_LOADERS = self._old_template_loaders self.template_file.close() manifest_path = os.path.join("CACHE", "manifest.json") if default_storage.exists(manifest_path): default_storage.delete(manifest_path)
def _test_deleting_manifest_does_not_affect_rendering(self, engine): count, result = CompressCommand().compress( log=self.log, verbosity=self.verbosity, engine=engine) get_offline_manifest() manifest_path = os.path.join('CACHE', 'manifest.json') if default_storage.exists(manifest_path): default_storage.delete(manifest_path) self.assertEqual(1, count) self.assertEqual([self._render_script(self.expected_hash)], result) rendered_template = self._render_template(engine) self.assertEqual(rendered_template, self._render_result(result))
def _test_deleting_manifest_does_not_affect_rendering(self, engine): count, result = CompressCommand().handle_inner(engines=[engine], verbosity=0) get_offline_manifest() manifest_path = os.path.join('CACHE', 'manifest.json') if default_storage.exists(manifest_path): default_storage.delete(manifest_path) self.assertEqual(1, count) self.assertEqual([self._render_script(self.expected_hash)], result) rendered_template = self._render_template(engine) self.assertEqual(rendered_template, self._render_result(result))
def _test_deleting_manifest_does_not_affect_rendering(self, engine): count, result = CompressCommand().compress(log=self.log, verbosity=self.verbosity, engine=engine) get_offline_manifest() manifest_path = os.path.join("CACHE", "manifest.json") if default_storage.exists(manifest_path): default_storage.delete(manifest_path) self.assertEqual(1, count) self.assertEqual( ['<script type="text/javascript" src="/static/CACHE/js/' '%s.js"></script>' % (self.expected_hash,)], result ) rendered_template = self._render_template(engine) self.assertEqual(rendered_template, "".join(result) + "\n")
def test_deleting_manifest_does_not_affect_rendering(self): count, result = CompressCommand().compress(log=self.log, verbosity=self.verbosity) get_offline_manifest() manifest_path = os.path.join('CACHE', 'manifest.json') if default_storage.exists(manifest_path): default_storage.delete(manifest_path) self.assertEqual(1, count) self.assertEqual([ u'<script type="text/javascript" src="/media/CACHE/js/%s.js"></script>' % (self.expected_hash, ), ], result) rendered_template = self.template.render(Context(settings.COMPRESS_OFFLINE_CONTEXT)) self.assertEqual(rendered_template, "".join(result) + "\n")
def _test_deleting_manifest_does_not_affect_rendering(self, engine): count, result = CompressCommand().compress(log=self.log, verbosity=self.verbosity, engine=engine) get_offline_manifest() manifest_path = os.path.join("CACHE", "manifest.json") if default_storage.exists(manifest_path): default_storage.delete(manifest_path) self.assertEqual(1, count) self.assertEqual([self._render_script(self.expected_hash)], result) rendered_template = self._render_template(engine) self.assertEqual(rendered_template, self._render_result(result))
def _test_deleting_manifest_does_not_affect_rendering(self, engine): count, result = CompressCommand().compress(log=self.log, verbosity=self.verbosity, engine=engine) get_offline_manifest() manifest_path = os.path.join('CACHE', 'manifest.json') if default_storage.exists(manifest_path): default_storage.delete(manifest_path) self.assertEqual(1, count) self.assertEqual([ '<script type="text/javascript" src="/static/CACHE/js/%s.js"></script>' % (self.expected_hash, ), ], result) rendered_template = self._render_template(engine) self.assertEqual(rendered_template, "".join(result) + "\n")
def tearDown(self): settings.COMPRESS_ENABLED = self._old_compress settings.COMPRESS_OFFLINE = self._old_compress_offline self.template_file.close() if default_storage.exists('CACHE/manifest.json'): default_storage.delete('CACHE/manifest.json')
def tearDown(self): self.override_settings.__exit__(None, None, None) manifest_path = os.path.join('CACHE', 'manifest.json') if default_storage.exists(manifest_path): default_storage.delete(manifest_path)