Commit e0ff4d47 by Timothée Peignier

fix tests

parent bb5d2b68
# -*- coding: utf-8 flake8: noqa -*- # -*- coding: utf-8 flake8: noqa -*-
from .test_compiler import * from .test_compiler import *
from .test_compressor import * from .test_compressor import *
from .test_extension import * from .test_template import *
from .test_glob import * from .test_glob import *
from .test_middleware import * from .test_middleware import *
from .test_packager import * from .test_packager import *
......
...@@ -3,39 +3,25 @@ from __future__ import unicode_literals ...@@ -3,39 +3,25 @@ from __future__ import unicode_literals
from django.test import TestCase from django.test import TestCase
from django.utils.datastructures import SortedDict from django.utils.datastructures import SortedDict
from pipeline.conf import settings
from pipeline.storage import PipelineStorage from pipeline.storage import PipelineStorage
from tests.utils import _ from tests.utils import pipeline_settings
class StorageTest(TestCase): class StorageTest(TestCase):
def setUp(self): def setUp(self):
settings.PIPELINE_CSS = {
'testing': {
'source_filenames': (
_('pipeline/css/first.css'),
_('css/third.css'),
),
'manifest': False,
'output_filename': 'testing.css',
}
}
settings.PIPELINE_JS_COMPRESSOR = None
settings.PIPELINE_CSS_COMPRESSOR = None
self.storage = PipelineStorage() self.storage = PipelineStorage()
def test_post_process_dry_run(self): def test_post_process_dry_run(self):
with pipeline_settings(PIPELINE_JS_COMPRESSOR=None, PIPELINE_CSS_COMPRESSOR=None):
processed_files = self.storage.post_process([], True) processed_files = self.storage.post_process([], True)
self.assertEqual(processed_files, []) self.assertEqual(processed_files, [])
def test_post_process(self): def test_post_process(self):
with pipeline_settings(PIPELINE_JS_COMPRESSOR=None, PIPELINE_CSS_COMPRESSOR=None):
processed_files = self.storage.post_process(SortedDict({ processed_files = self.storage.post_process(SortedDict({
'css/first.css': (self.storage, 'css/first.css'), 'css/first.css': (self.storage, 'css/first.css'),
'images/arrow.png': (self.storage, 'images/arrow.png') 'images/arrow.png': (self.storage, 'images/arrow.png')
})) }))
self.assertTrue(('css/first.css', 'css/first.css', True) in processed_files) self.assertTrue(('css/first.css', 'css/first.css', True) in processed_files)
self.assertTrue(('images/arrow.png', 'images/arrow.png', True) in processed_files) self.assertTrue(('images/arrow.png', 'images/arrow.png', True) in processed_files)
def tearDown(self):
settings.PIPELINE_CSS = {}
...@@ -3,6 +3,7 @@ from __future__ import unicode_literals ...@@ -3,6 +3,7 @@ from __future__ import unicode_literals
from jinja2 import Environment, PackageLoader from jinja2 import Environment, PackageLoader
from django.template import Template, Context
from django.test import TestCase from django.test import TestCase
from pipeline.jinja2.ext import PipelineExtension from pipeline.jinja2.ext import PipelineExtension
...@@ -10,7 +11,7 @@ from pipeline.jinja2.ext import PipelineExtension ...@@ -10,7 +11,7 @@ from pipeline.jinja2.ext import PipelineExtension
from tests.utils import pipeline_settings from tests.utils import pipeline_settings
class ExtensionTest(TestCase): class JinjaTest(TestCase):
def setUp(self): def setUp(self):
self.env = Environment(extensions=[PipelineExtension], loader= self.env = Environment(extensions=[PipelineExtension], loader=
PackageLoader('pipeline', 'templates')) PackageLoader('pipeline', 'templates'))
...@@ -35,3 +36,12 @@ class ExtensionTest(TestCase): ...@@ -35,3 +36,12 @@ class ExtensionTest(TestCase):
def test_package_js(self): def test_package_js(self):
template = self.env.from_string(u"""{% compressed_js "scripts" %}""") template = self.env.from_string(u"""{% compressed_js "scripts" %}""")
self.assertEqual(u'<script type="text/css" src="/static/scripts.css" charset="utf-8"></script>', template.render()) self.assertEqual(u'<script type="text/css" src="/static/scripts.css" charset="utf-8"></script>', template.render())
class DjangoTest(TestCase):
def render_template(self, template):
return Template(template).render(Context())
def test_compressed_css(self):
rendered = self.render_template(u"""{% load compressed %}{% compressed_css "unknow" %}""")
self.assertEqual(u"", rendered)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment