コード例 #1
0
ファイル: test_offline.py プロジェクト: holachek/ecosense
 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)
コード例 #2
0
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
コード例 #3
0
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
コード例 #4
0
 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)
コード例 #5
0
ファイル: test_offline.py プロジェクト: jesobreira/casanova
 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)
コード例 #6
0
ファイル: test_offline.py プロジェクト: jokar/minion
 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)
コード例 #7
0
 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))
コード例 #8
0
 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))
コード例 #9
0
 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")
コード例 #10
0
 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")
コード例 #11
0
 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))
コード例 #12
0
ファイル: test_offline.py プロジェクト: jesobreira/casanova
 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")
コード例 #13
0
 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")
コード例 #14
0
 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')
コード例 #15
0
    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)
コード例 #16
0
 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')
コード例 #17
0
    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)