Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-pipeline
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
django-pipeline
Commits
cc66882b
Commit
cc66882b
authored
Feb 21, 2012
by
Timothée Peignier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get rid of PIPELINE_ROOT
parent
0915e438
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
11 additions
and
30 deletions
+11
-30
pipeline/compressors/__init__.py
+3
-3
pipeline/conf/settings.py
+0
-2
tests/settings.py
+0
-2
tests/tests/compressor.py
+2
-18
tests/tests/storage.py
+6
-5
No files found.
pipeline/compressors/__init__.py
View file @
cc66882b
...
...
@@ -217,15 +217,15 @@ class Compressor(object):
given the path of the stylesheet that contains it.
"""
if
os
.
path
.
isabs
(
path
):
path
=
os
.
path
.
join
(
s
ettings
.
PIPELINE_ROOT
,
path
)
path
=
os
.
path
.
join
(
s
torage
.
location
,
path
)
else
:
path
=
os
.
path
.
join
(
start
,
path
)
return
os
.
path
.
normpath
(
path
)
def
relative_path
(
self
,
absolute_path
):
"""Rewrite paths relative to the output stylesheet path"""
absolute_path
=
self
.
absolute_path
(
absolute_path
,
s
ettings
.
PIPELINE_ROOT
)
return
os
.
path
.
join
(
os
.
sep
,
relpath
(
absolute_path
,
s
ettings
.
PIPELINE_ROOT
))
absolute_path
=
self
.
absolute_path
(
absolute_path
,
s
torage
.
location
)
return
os
.
path
.
join
(
os
.
sep
,
relpath
(
absolute_path
,
s
torage
.
location
))
def
read_file
(
self
,
path
):
"""Read file content in binary mode"""
...
...
pipeline/conf/settings.py
View file @
cc66882b
...
...
@@ -2,10 +2,8 @@ from django.conf import settings
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_STORAGE
=
getattr
(
settings
,
'PIPELINE_STORAGE'
,
'pipeline.storage.PipelineFinderStorage'
)
...
...
tests/settings.py
View file @
cc66882b
...
...
@@ -35,8 +35,6 @@ STATICFILES_FINDERS = (
'staticfiles.finders.AppDirectoriesFinder'
)
PIPELINE_ROOT
=
local_path
(
'assets/'
)
TEMPLATE_DIRS
=
(
local_path
(
'templates'
),
)
...
...
tests/tests/compressor.py
View file @
cc66882b
# -*- coding: utf-8 -*-
import
base64
import
sys
from
mock
import
patch
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.yui
import
YUICompressor
from
pipeline.storage
import
storage
class
CompressorTest
(
TestCase
):
def
setUp
(
self
):
self
.
compressor
=
Compressor
()
self
.
old_pipeline_root
=
settings
.
PIPELINE_ROOT
def
test_js_compressor_class
(
self
):
self
.
assertEquals
(
self
.
compressor
.
js_compressor
,
YUICompressor
)
...
...
@@ -49,8 +43,7 @@ class CompressorTest(TestCase):
self
.
assertFalse
(
mock
.
called
)
def
test_relative_path
(
self
):
settings
.
PIPELINE_ROOT
=
'/var/www/static/'
relative_path
=
self
.
compressor
.
relative_path
(
'/var/www/static/images/sprite.png'
)
relative_path
=
self
.
compressor
.
relative_path
(
"
%
s/images/sprite.png"
%
storage
.
location
)
self
.
assertEquals
(
relative_path
,
'/images/sprite.png'
)
def
test_base_path
(
self
):
...
...
@@ -100,12 +93,6 @@ class CompressorTest(TestCase):
"css/plugins/gallery.css"
)
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
):
asset_path
=
self
.
compressor
.
construct_asset_path
(
"../../images/sprite.png"
,
"css/plugins/gallery.css"
,
...
...
@@ -140,6 +127,3 @@ class CompressorTest(TestCase):
.no-protocol-url {
background-image: url(//images/sprite-buttons.png);
}"""
,
output
)
def
tearDown
(
self
):
settings
.
PIPELINE_ROOT
=
self
.
old_pipeline_root
tests/tests/storage.py
View file @
cc66882b
from
django.test
import
TestCase
from
django.utils.datastructures
import
SortedDict
from
pipeline.conf
import
settings
from
pipeline.storage
import
PipelineStorage
...
...
@@ -24,11 +25,11 @@ class StorageTest(TestCase):
self
.
assertEqual
(
processed_files
,
[])
def
test_post_process
(
self
):
processed_files
=
self
.
storage
.
post_process
(
[
'css/first.css'
,
'images/arrow.png'
]
)
self
.
assertEqual
(
processed_files
,
[
processed_files
=
self
.
storage
.
post_process
(
SortedDict
({
'css/first.css'
:
(
self
.
storage
,
'css/first.css'
)
,
'images/arrow.png'
:
(
self
.
storage
,
'images/arrow.png'
)
})
)
self
.
assertEqual
(
processed_files
.
keys
()
,
[
'css/first.css'
,
'images/arrow.png'
,
'testing.css'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment