Commit 27a51434 by Timothée Peignier

add more tests

parent b239323e
......@@ -7,4 +7,6 @@ build
dist
MANIFEST
docs/_build/
*.egg-info
\ No newline at end of file
*.egg-info
.coverage
htmlcov/
\ No newline at end of file
#!/usr/bin/env python
import coverage
import os
import sys
......@@ -30,8 +31,24 @@ from django.test.simple import run_tests
def runtests(*test_args):
if not test_args:
test_args = ['tests']
parent_dir = os.path.join(TEST_DIR, "..")
sys.path.insert(0, os.path.join(TEST_DIR, ".."))
cover = coverage.coverage(branch=True, cover_pylib=False,
include=[
os.path.join(parent_dir, 'pipeline', '*.py')
],
omit=[
os.path.join(parent_dir, 'tests', '*.py'),
os.path.join(parent_dir, 'pipeline', 'compressors',
'jsmin', 'jsmin.py'),
]
)
cover.load()
cover.start()
failures = run_tests(test_args, verbosity=1, interactive=True)
cover.stop()
cover.save()
cover.report(file=sys.stdout)
sys.exit(failures)
......
.concat {
display: none;
}
\ No newline at end of file
.concatenate {
display: block;
}
\ No newline at end of file
function concat() {
console.log(arguments);
}
\ No newline at end of file
function cat() {
console.log("hello world");
}
\ No newline at end of file
<div class="photo">
<img src="<%= src %>" />
<div class="caption">
<%= caption %>
</div>
</div>
\ No newline at end of file
......@@ -4,13 +4,37 @@ from django.test import TestCase
from pipeline.conf import settings
from pipeline.compressors import Compressor
from pipeline.compressors.yui import YUICompressor
class CompressorTest(TestCase):
def setUp(self):
self.old_pipeline_url = settings.PIPELINE_URL
settings.PIPELINE_URL = 'http://localhost/static/'
def test_js_compressor_class(self):
compressor = Compressor()
self.assertEquals(compressor.js_compressor, YUICompressor)
def test_css_compressor_class(self):
compressor = Compressor()
self.assertEquals(compressor.css_compressor, YUICompressor)
def test_concatenate_and_rewrite(self):
compressor = Compressor()
css = compressor.concatenate_and_rewrite([
os.path.join(settings.PIPELINE_ROOT, 'css/first.css'),
os.path.join(settings.PIPELINE_ROOT, 'css/second.css')
])
self.assertEquals(""".concat {\n display: none;\n}\n.concatenate {\n display: block;\n}""", css)
def test_concatenate(self):
compressor = Compressor()
js = compressor.concatenate([
os.path.join(settings.PIPELINE_ROOT, 'js/first.js'),
os.path.join(settings.PIPELINE_ROOT, 'js/second.js')
])
self.assertEquals("""(function() { function concat() {\n console.log(arguments);\n}\nfunction cat() {\n console.log("hello world");\n} }).call(this);""", js)
def test_url_rewrite(self):
compressor = Compressor()
output = compressor.concatenate_and_rewrite([
......
......@@ -3,7 +3,7 @@ import os
from django.test import TestCase
from pipeline.conf import settings
from pipeline.packager import Packager
from pipeline.packager import Packager, PackageNotFound
class PackagerTest(TestCase):
......@@ -11,6 +11,45 @@ class PackagerTest(TestCase):
self.old_pipeline_url = settings.PIPELINE_URL
settings.PIPELINE_URL = 'http://localhost/static/'
def test_package_for(self):
packager = Packager()
packager.packages['js'] = packager.create_packages({
'application': {
'source_filenames': (
'js/application.js',
),
'output_filename': 'application.r?.js'
}
})
try:
packager.package_for('js', 'application')
except PackageNotFound:
self.fail()
try:
packager.package_for('js', 'broken')
self.fail()
except PackageNotFound:
pass
def test_templates(self):
packager = Packager()
packages = packager.create_packages({
'templates': {
'source_filenames': (
'templates/photo/list.jst',
),
'output_filename': 'templates.r?.js',
}
})
self.assertEqual(packages, {
'templates': {
'templates': ['templates/photo/list.jst'],
'paths': [],
'context': {},
'output': 'templates.r?.js'
}
})
def test_individual_url(self):
"""Check that individual URL is correctly generated"""
packager = Packager()
......
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