Commit cc66882b by Timothée Peignier

get rid of PIPELINE_ROOT

parent 0915e438
...@@ -217,15 +217,15 @@ class Compressor(object): ...@@ -217,15 +217,15 @@ class Compressor(object):
given the path of the stylesheet that contains it. given the path of the stylesheet that contains it.
""" """
if os.path.isabs(path): if os.path.isabs(path):
path = os.path.join(settings.PIPELINE_ROOT, path) path = os.path.join(storage.location, path)
else: else:
path = os.path.join(start, path) path = os.path.join(start, path)
return os.path.normpath(path) return os.path.normpath(path)
def relative_path(self, absolute_path): def relative_path(self, absolute_path):
"""Rewrite paths relative to the output stylesheet path""" """Rewrite paths relative to the output stylesheet path"""
absolute_path = self.absolute_path(absolute_path, settings.PIPELINE_ROOT) absolute_path = self.absolute_path(absolute_path, storage.location)
return os.path.join(os.sep, relpath(absolute_path, settings.PIPELINE_ROOT)) return os.path.join(os.sep, relpath(absolute_path, storage.location))
def read_file(self, path): def read_file(self, path):
"""Read file content in binary mode""" """Read file content in binary mode"""
......
...@@ -2,10 +2,8 @@ from django.conf import settings ...@@ -2,10 +2,8 @@ from django.conf import settings
PIPELINE = getattr(settings, 'PIPELINE', not settings.DEBUG) PIPELINE = getattr(settings, 'PIPELINE', not settings.DEBUG)
PIPELINE_ROOT = getattr(settings, 'PIPELINE_ROOT', settings.STATIC_ROOT)
PIPELINE_URL = getattr(settings, 'PIPELINE_URL', settings.STATIC_URL) PIPELINE_URL = getattr(settings, 'PIPELINE_URL', settings.STATIC_URL)
PIPELINE_STORAGE = getattr(settings, 'PIPELINE_STORAGE', PIPELINE_STORAGE = getattr(settings, 'PIPELINE_STORAGE',
'pipeline.storage.PipelineFinderStorage') 'pipeline.storage.PipelineFinderStorage')
......
...@@ -35,8 +35,6 @@ STATICFILES_FINDERS = ( ...@@ -35,8 +35,6 @@ STATICFILES_FINDERS = (
'staticfiles.finders.AppDirectoriesFinder' 'staticfiles.finders.AppDirectoriesFinder'
) )
PIPELINE_ROOT = local_path('assets/')
TEMPLATE_DIRS = ( TEMPLATE_DIRS = (
local_path('templates'), local_path('templates'),
) )
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import base64 import base64
import sys
from mock import patch from mock import patch
from django.test import TestCase from django.test import TestCase
try:
from django.utils import unittest
except ImportError:
import unittest2 as unittest
from pipeline.conf import settings
from pipeline.compressors import Compressor, TEMPLATE_FUNC from pipeline.compressors import Compressor, TEMPLATE_FUNC
from pipeline.compressors.yui import YUICompressor from pipeline.compressors.yui import YUICompressor
from pipeline.storage import storage
class CompressorTest(TestCase): class CompressorTest(TestCase):
def setUp(self): def setUp(self):
self.compressor = Compressor() self.compressor = Compressor()
self.old_pipeline_root = settings.PIPELINE_ROOT
def test_js_compressor_class(self): def test_js_compressor_class(self):
self.assertEquals(self.compressor.js_compressor, YUICompressor) self.assertEquals(self.compressor.js_compressor, YUICompressor)
...@@ -49,8 +43,7 @@ class CompressorTest(TestCase): ...@@ -49,8 +43,7 @@ class CompressorTest(TestCase):
self.assertFalse(mock.called) self.assertFalse(mock.called)
def test_relative_path(self): def test_relative_path(self):
settings.PIPELINE_ROOT = '/var/www/static/' relative_path = self.compressor.relative_path("%s/images/sprite.png" % storage.location)
relative_path = self.compressor.relative_path('/var/www/static/images/sprite.png')
self.assertEquals(relative_path, '/images/sprite.png') self.assertEquals(relative_path, '/images/sprite.png')
def test_base_path(self): def test_base_path(self):
...@@ -100,12 +93,6 @@ class CompressorTest(TestCase): ...@@ -100,12 +93,6 @@ class CompressorTest(TestCase):
"css/plugins/gallery.css") "css/plugins/gallery.css")
self.assertEquals(asset_path, "images/sprite.png") self.assertEquals(asset_path, "images/sprite.png")
@unittest.skipUnless(sys.platform.startswith("win"), "requires Windows")
def test_construct_asset_path_windows(self):
asset_path = self.compressor.construct_asset_path("\image\sprite.png",
"css\plugins\gallery.css")
self.assertEquals(asset_path, "http://localhost/static/images/sprite.png")
def test_construct_asset_path_relative(self): def test_construct_asset_path_relative(self):
asset_path = self.compressor.construct_asset_path("../../images/sprite.png", asset_path = self.compressor.construct_asset_path("../../images/sprite.png",
"css/plugins/gallery.css", "css/plugins/gallery.css",
...@@ -140,6 +127,3 @@ class CompressorTest(TestCase): ...@@ -140,6 +127,3 @@ class CompressorTest(TestCase):
.no-protocol-url { .no-protocol-url {
background-image: url(//images/sprite-buttons.png); background-image: url(//images/sprite-buttons.png);
}""", output) }""", output)
def tearDown(self):
settings.PIPELINE_ROOT = self.old_pipeline_root
from django.test import TestCase from django.test import TestCase
from django.utils.datastructures import SortedDict
from pipeline.conf import settings from pipeline.conf import settings
from pipeline.storage import PipelineStorage from pipeline.storage import PipelineStorage
...@@ -24,11 +25,11 @@ class StorageTest(TestCase): ...@@ -24,11 +25,11 @@ class StorageTest(TestCase):
self.assertEqual(processed_files, []) self.assertEqual(processed_files, [])
def test_post_process(self): def test_post_process(self):
processed_files = self.storage.post_process([ processed_files = self.storage.post_process(SortedDict({
'css/first.css', 'css/first.css': (self.storage, 'css/first.css'),
'images/arrow.png' 'images/arrow.png': (self.storage, 'images/arrow.png')
]) }))
self.assertEqual(processed_files, [ self.assertEqual(processed_files.keys(), [
'css/first.css', 'css/first.css',
'images/arrow.png', 'images/arrow.png',
'testing.css', 'testing.css',
......
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