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
ff481dec
Commit
ff481dec
authored
Jan 08, 2015
by
Brad Pitcher
Committed by
Timothée Peignier
Feb 22, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow to work with storages not implementing the path method.
parent
1f786078
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
1 deletions
+55
-1
pipeline/compilers/__init__.py
+5
-1
tests/tests/test_storage.py
+50
-0
No files found.
pipeline/compilers/__init__.py
View file @
ff481dec
...
...
@@ -7,6 +7,7 @@ try:
except
ImportError
:
from
pipes
import
quote
from
django.contrib.staticfiles
import
finders
from
django.contrib.staticfiles.storage
import
staticfiles_storage
from
django.core.files.base
import
ContentFile
from
django.utils.encoding
import
smart_str
,
smart_bytes
...
...
@@ -33,7 +34,10 @@ class Compiler(object):
compiler
=
compiler
(
verbose
=
self
.
verbose
,
storage
=
self
.
storage
)
if
compiler
.
match_file
(
input_path
):
output_path
=
self
.
output_path
(
input_path
,
compiler
.
output_extension
)
infile
=
self
.
storage
.
path
(
input_path
)
try
:
infile
=
self
.
storage
.
path
(
input_path
)
except
NotImplementedError
:
infile
=
finders
.
find
(
input_path
)
outfile
=
self
.
output_path
(
infile
,
compiler
.
output_extension
)
outdated
=
compiler
.
is_outdated
(
input_path
,
output_path
)
try
:
...
...
tests/tests/test_storage.py
View file @
ff481dec
from
__future__
import
unicode_literals
from
django.contrib.staticfiles.storage
import
staticfiles_storage
from
django.core.management
import
call_command
from
django.test
import
TestCase
from
django.test.utils
import
override_settings
from
pipeline.storage
import
PipelineStorage
from
tests.tests.test_compiler
import
DummyCompiler
from
tests.utils
import
pipeline_settings
try
:
from
io
import
StringIO
except
ImportError
:
from
StringIO
import
StringIO
class
PipelineNoPathStorage
(
PipelineStorage
):
"""Storage without an implemented path method"""
def
path
(
self
,
*
args
):
raise
NotImplementedError
()
def
delete
(
self
,
*
args
):
return
def
exists
(
self
,
*
args
):
return
True
def
save
(
self
,
*
args
):
return
def
open
(
self
,
*
args
):
return
StringIO
()
class
DummyCSSCompiler
(
DummyCompiler
):
""" Handles css files """
output_extension
=
'css'
def
match_file
(
self
,
path
):
return
path
.
endswith
(
'.css'
)
class
StorageTest
(
TestCase
):
def
tearDown
(
self
):
staticfiles_storage
.
_setup
()
def
test_post_process_dry_run
(
self
):
with
pipeline_settings
(
PIPELINE_JS_COMPRESSOR
=
None
,
PIPELINE_CSS_COMPRESSOR
=
None
):
processed_files
=
PipelineStorage
()
.
post_process
({},
True
)
...
...
@@ -19,3 +57,15 @@ class StorageTest(TestCase):
processed_files
=
storage
.
post_process
({})
self
.
assertTrue
((
'screen.css'
,
'screen.css'
,
True
)
in
processed_files
)
self
.
assertTrue
((
'scripts.js'
,
'scripts.js'
,
True
)
in
processed_files
)
def
test_post_process_no_path
(
self
):
"""
Test post_process with a storage that doesn't implement the path method.
"""
with
override_settings
(
STATICFILES_STORAGE
=
'tests.tests.test_storage.PipelineNoPathStorage'
,
PIPELINE_COMPILERS
=
[
'tests.tests.test_storage.DummyCSSCompiler'
]):
with
pipeline_settings
(
PIPELINE_JS_COMPRESSOR
=
None
,
PIPELINE_CSS_COMPRESSOR
=
None
):
staticfiles_storage
.
_setup
()
try
:
call_command
(
'collectstatic'
,
verbosity
=
0
,
interactive
=
False
)
except
NotImplementedError
:
self
.
fail
(
'Received an error running collectstatic'
)
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