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
9bebcbfb
Commit
9bebcbfb
authored
Sep 04, 2012
by
idan
Committed by
Timothée Peignier
Sep 05, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix tests and compatibility for windows environment
parent
dfd4cbb3
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
39 additions
and
26 deletions
+39
-26
pipeline/compressors/__init__.py
+2
-2
tests/tests/compiler.py
+5
-3
tests/tests/compressor.py
+18
-16
tests/tests/packager.py
+5
-3
tests/tests/paths.py
+6
-0
tests/tests/storage.py
+3
-2
No files found.
pipeline/compressors/__init__.py
View file @
9bebcbfb
...
...
@@ -154,11 +154,11 @@ class Compressor(object):
def
embeddable
(
self
,
path
,
variant
):
"""Is the asset embeddable ?"""
name
,
ext
=
posix
path
.
splitext
(
path
)
name
,
ext
=
os
.
path
.
splitext
(
path
)
font
=
ext
in
FONT_EXTS
if
not
variant
:
return
False
if
not
(
re
.
search
(
settings
.
PIPELINE_EMBED_PATH
,
path
)
and
self
.
storage
.
exists
(
path
)):
if
not
(
re
.
search
(
settings
.
PIPELINE_EMBED_PATH
,
path
.
replace
(
'
\\
'
,
'/'
)
)
and
self
.
storage
.
exists
(
path
)):
return
False
if
not
ext
in
EMBED_EXTS
:
return
False
...
...
tests/tests/compiler.py
View file @
9bebcbfb
...
...
@@ -3,6 +3,8 @@ from django.test import TestCase
from
pipeline.conf
import
settings
from
pipeline.compilers
import
Compiler
,
CompilerBase
from
paths
import
_
class
DummyCompiler
(
CompilerBase
):
output_extension
=
'js'
...
...
@@ -30,10 +32,10 @@ class CompilerTest(TestCase):
def
test_compile
(
self
):
paths
=
self
.
compiler
.
compile
([
'pipeline/js/dummy.coffee'
,
'pipeline/js/application.js'
,
_
(
'pipeline/js/dummy.coffee'
)
,
_
(
'pipeline/js/application.js'
)
,
])
self
.
assertEquals
([
'pipeline/js/dummy.js'
,
'pipeline/js/application.js'
],
paths
)
self
.
assertEquals
([
_
(
'pipeline/js/dummy.js'
),
_
(
'pipeline/js/application.js'
)
],
paths
)
def
tearDown
(
self
):
settings
.
PIPELINE_COMPILERS
=
self
.
old_compilers
tests/tests/compressor.py
View file @
9bebcbfb
...
...
@@ -8,6 +8,8 @@ from django.test import TestCase
from
pipeline.compressors
import
Compressor
,
TEMPLATE_FUNC
from
pipeline.compressors.yui
import
YUICompressor
from
paths
import
_
class
CompressorTest
(
TestCase
):
def
setUp
(
self
):
...
...
@@ -22,24 +24,24 @@ class CompressorTest(TestCase):
def
test_concatenate_and_rewrite
(
self
):
css
=
self
.
compressor
.
concatenate_and_rewrite
([
'pipeline/css/first.css'
,
'pipeline/css/second.css'
_
(
'pipeline/css/first.css'
)
,
_
(
'pipeline/css/second.css'
)
],
'css/screen.css'
)
self
.
assertEquals
(
""".concat {
\n
display: none;
\n
}
\n\n
.concatenate {
\n
display: block;
\n
}
\n
"""
,
css
)
def
test_concatenate
(
self
):
js
=
self
.
compressor
.
concatenate
([
'pipeline/js/first.js'
,
'pipeline/js/second.js'
_
(
'pipeline/js/first.js'
)
,
_
(
'pipeline/js/second.js'
)
])
self
.
assertEquals
(
"""function concat() {
\n
console.log(arguments);
\n
}
\n\n
function cat() {
\n
console.log("hello world");
\n
}
\n
"""
,
js
)
@patch.object
(
base64
,
'b64encode'
)
def
test_encoded_content
(
self
,
mock
):
self
.
compressor
.
encoded_content
(
'pipeline/images/arrow.png'
)
self
.
compressor
.
encoded_content
(
_
(
'pipeline/images/arrow.png'
)
)
self
.
assertTrue
(
mock
.
called
)
mock
.
reset_mock
()
self
.
compressor
.
encoded_content
(
'pipeline/images/arrow.png'
)
self
.
compressor
.
encoded_content
(
_
(
'pipeline/images/arrow.png'
)
)
self
.
assertFalse
(
mock
.
called
)
def
test_relative_path
(
self
):
...
...
@@ -48,9 +50,9 @@ class CompressorTest(TestCase):
def
test_base_path
(
self
):
base_path
=
self
.
compressor
.
base_path
([
'js/templates/form.jst'
,
'js/templates/field.jst'
_
(
'js/templates/form.jst'
),
_
(
'js/templates/field.jst'
)
])
self
.
assertEquals
(
base_path
,
'js/templates'
)
self
.
assertEquals
(
base_path
,
_
(
'js/templates'
)
)
def
test_absolute_path
(
self
):
absolute_path
=
self
.
compressor
.
absolute_path
(
'../../images/sprite.png'
,
...
...
@@ -71,19 +73,19 @@ class CompressorTest(TestCase):
self
.
assertEquals
(
name
,
'photo_detail'
)
def
test_compile_templates
(
self
):
templates
=
self
.
compressor
.
compile_templates
([
'pipeline/templates/photo/list.jst'
])
templates
=
self
.
compressor
.
compile_templates
([
_
(
'pipeline/templates/photo/list.jst'
)
])
self
.
assertEquals
(
templates
,
"""window.JST = window.JST || {};
\n
%
s
\n
window.JST[
\'
list
\'
] = template(
\'
<div class="photo">
\\
n <img src="<
%%
= src
%%
>" />
\\
n <div class="caption">
\\
n <
%%
= caption
%%
>
\\
n </div>
\\
n</div>
\'
);
\n
"""
%
TEMPLATE_FUNC
)
templates
=
self
.
compressor
.
compile_templates
([
'pipeline/templates/video/detail.jst'
,
'pipeline/templates/photo/detail.jst'
_
(
'pipeline/templates/video/detail.jst'
)
,
_
(
'pipeline/templates/photo/detail.jst'
)
])
self
.
assertEqual
(
templates
,
"""window.JST = window.JST || {};
\n
%
s
\n
window.JST[
\'
video_detail
\'
] = template(
\'
<div class="video">
\\
n <video src="<
%%
= src
%%
>" />
\\
n <div class="caption">
\\
n <
%%
= description
%%
>
\\
n </div>
\\
n</div>
\'
);
\n
window.JST[
\'
photo_detail
\'
] = template(
\'
<div class="photo">
\\
n <img src="<
%%
= src
%%
>" />
\\
n <div class="caption">
\\
n <
%%
= caption
%%
> by <
%%
= author
%%
>
\\
n </div>
\\
n</div>
\'
);
\n
"""
%
TEMPLATE_FUNC
)
def
test_embeddable
(
self
):
self
.
assertFalse
(
self
.
compressor
.
embeddable
(
'pipeline/images/sprite.png'
,
None
))
self
.
assertFalse
(
self
.
compressor
.
embeddable
(
'pipeline/images/arrow.png'
,
'datauri'
))
self
.
assertTrue
(
self
.
compressor
.
embeddable
(
'pipeline/images/embed/arrow.png'
,
'datauri'
))
self
.
assertFalse
(
self
.
compressor
.
embeddable
(
'pipeline/images/arrow.dat'
,
'datauri'
))
self
.
assertFalse
(
self
.
compressor
.
embeddable
(
_
(
'pipeline/images/sprite.png'
)
,
None
))
self
.
assertFalse
(
self
.
compressor
.
embeddable
(
_
(
'pipeline/images/arrow.png'
)
,
'datauri'
))
self
.
assertTrue
(
self
.
compressor
.
embeddable
(
_
(
'pipeline/images/embed/arrow.png'
)
,
'datauri'
))
self
.
assertFalse
(
self
.
compressor
.
embeddable
(
_
(
'pipeline/images/arrow.dat'
)
,
'datauri'
))
def
test_construct_asset_path
(
self
):
asset_path
=
self
.
compressor
.
construct_asset_path
(
"../../images/sprite.png"
,
...
...
@@ -95,7 +97,7 @@ class CompressorTest(TestCase):
def
test_url_rewrite
(
self
):
output
=
self
.
compressor
.
concatenate_and_rewrite
([
'pipeline/css/urls.css'
,
_
(
'pipeline/css/urls.css'
)
,
],
'css/screen.css'
)
self
.
assertEquals
(
u"""@font-face {
font-family: 'Pipeline';
...
...
tests/tests/packager.py
View file @
9bebcbfb
...
...
@@ -2,6 +2,8 @@ from django.test import TestCase
from
pipeline.packager
import
Packager
,
PackageNotFound
from
paths
import
_
class
PackagerTest
(
TestCase
):
def
test_package_for
(
self
):
...
...
@@ -9,7 +11,7 @@ class PackagerTest(TestCase):
packager
.
packages
[
'js'
]
=
packager
.
create_packages
({
'application'
:
{
'source_filenames'
:
(
'pipeline/js/application.js'
,
_
(
'pipeline/js/application.js'
)
,
),
'output_filename'
:
'application.js'
}
...
...
@@ -29,9 +31,9 @@ class PackagerTest(TestCase):
packages
=
packager
.
create_packages
({
'templates'
:
{
'source_filenames'
:
(
'pipeline/templates/photo/list.jst'
,
_
(
'pipeline/templates/photo/list.jst'
)
,
),
'output_filename'
:
'templates.js'
,
}
})
self
.
assertEqual
(
packages
[
'templates'
]
.
templates
,
[
'pipeline/templates/photo/list.jst'
])
self
.
assertEqual
(
packages
[
'templates'
]
.
templates
,
[
_
(
'pipeline/templates/photo/list.jst'
)
])
tests/tests/paths.py
0 → 100644
View file @
9bebcbfb
import
os
def
_
(
path
):
# Make sure the path contains only the correct separator
return
path
.
replace
(
'/'
,
os
.
sep
)
.
replace
(
'
\\
'
,
os
.
sep
)
tests/tests/storage.py
View file @
9bebcbfb
...
...
@@ -3,6 +3,7 @@ from django.utils.datastructures import SortedDict
from
pipeline.conf
import
settings
from
pipeline.storage
import
PipelineStorage
from
paths
import
_
class
StorageTest
(
TestCase
):
...
...
@@ -10,8 +11,8 @@ class StorageTest(TestCase):
settings
.
PIPELINE_CSS
=
{
'testing'
:
{
'source_filenames'
:
(
'pipeline/css/first.css'
,
'css/third.css'
,
_
(
'pipeline/css/first.css'
)
,
_
(
'css/third.css'
)
,
),
'manifest'
:
False
,
'output_filename'
:
'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