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
eb9e7e5d
Commit
eb9e7e5d
authored
Jan 28, 2013
by
Timothée Peignier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use assertEqual
parent
c75d5682
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
18 deletions
+18
-18
tests/tests/test_compiler.py
+3
-3
tests/tests/test_compressor.py
+15
-15
No files found.
tests/tests/test_compiler.py
View file @
eb9e7e5d
...
...
@@ -26,18 +26,18 @@ class CompilerTest(TestCase):
def
test_output_path
(
self
):
output_path
=
self
.
compiler
.
output_path
(
"js/helpers.coffee"
,
"js"
)
self
.
assertEqual
s
(
output_path
,
"js/helpers.js"
)
self
.
assertEqual
(
output_path
,
"js/helpers.js"
)
def
test_compilers_class
(
self
):
compilers_class
=
self
.
compiler
.
compilers
self
.
assertEqual
s
(
compilers_class
[
0
],
DummyCompiler
)
self
.
assertEqual
(
compilers_class
[
0
],
DummyCompiler
)
def
test_compile
(
self
):
paths
=
self
.
compiler
.
compile
([
_
(
'pipeline/js/dummy.coffee'
),
_
(
'pipeline/js/application.js'
),
])
self
.
assertEqual
s
([
_
(
'pipeline/js/dummy.js'
),
_
(
'pipeline/js/application.js'
)],
paths
)
self
.
assertEqual
([
_
(
'pipeline/js/dummy.js'
),
_
(
'pipeline/js/application.js'
)],
paths
)
def
tearDown
(
self
):
settings
.
PIPELINE_COMPILERS
=
self
.
old_compilers
tests/tests/test_compressor.py
View file @
eb9e7e5d
...
...
@@ -22,24 +22,24 @@ class CompressorTest(TestCase):
self
.
compressor
=
Compressor
()
def
test_js_compressor_class
(
self
):
self
.
assertEqual
s
(
self
.
compressor
.
js_compressor
,
YuglifyCompressor
)
self
.
assertEqual
(
self
.
compressor
.
js_compressor
,
YuglifyCompressor
)
def
test_css_compressor_class
(
self
):
self
.
assertEqual
s
(
self
.
compressor
.
css_compressor
,
YuglifyCompressor
)
self
.
assertEqual
(
self
.
compressor
.
css_compressor
,
YuglifyCompressor
)
def
test_concatenate_and_rewrite
(
self
):
css
=
self
.
compressor
.
concatenate_and_rewrite
([
_
(
'pipeline/css/first.css'
),
_
(
'pipeline/css/second.css'
)
],
'css/screen.css'
)
self
.
assertEqual
s
(
""".concat {
\n
display: none;
\n
}
\n\n
.concatenate {
\n
display: block;
\n
}
\n
"""
,
css
)
self
.
assertEqual
(
""".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'
)
])
self
.
assertEqual
s
(
"""function concat() {
\n
console.log(arguments);
\n
}
\n\n
function cat() {
\n
console.log("hello world");
\n
}
\n
"""
,
js
)
self
.
assertEqual
(
"""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
):
...
...
@@ -51,35 +51,35 @@ class CompressorTest(TestCase):
def
test_relative_path
(
self
):
relative_path
=
self
.
compressor
.
relative_path
(
"images/sprite.png"
,
'css/screen.css'
)
self
.
assertEqual
s
(
relative_path
,
'../images/sprite.png'
)
self
.
assertEqual
(
relative_path
,
'../images/sprite.png'
)
def
test_base_path
(
self
):
base_path
=
self
.
compressor
.
base_path
([
_
(
'js/templates/form.jst'
),
_
(
'js/templates/field.jst'
)
])
self
.
assertEqual
s
(
base_path
,
_
(
'js/templates'
))
self
.
assertEqual
(
base_path
,
_
(
'js/templates'
))
def
test_absolute_path
(
self
):
absolute_path
=
self
.
compressor
.
absolute_path
(
'../../images/sprite.png'
,
'css/plugins/'
)
self
.
assertEqual
s
(
absolute_path
,
'images/sprite.png'
)
self
.
assertEqual
(
absolute_path
,
'images/sprite.png'
)
absolute_path
=
self
.
compressor
.
absolute_path
(
'/images/sprite.png'
,
'css/plugins/'
)
self
.
assertEqual
s
(
absolute_path
,
'/images/sprite.png'
)
self
.
assertEqual
(
absolute_path
,
'/images/sprite.png'
)
def
test_template_name
(
self
):
name
=
self
.
compressor
.
template_name
(
'templates/photo/detail.jst'
,
'templates/'
)
self
.
assertEqual
s
(
name
,
'photo_detail'
)
self
.
assertEqual
(
name
,
'photo_detail'
)
name
=
self
.
compressor
.
template_name
(
'templates/photo_edit.jst'
,
''
)
self
.
assertEqual
s
(
name
,
'photo_edit'
)
self
.
assertEqual
(
name
,
'photo_edit'
)
name
=
self
.
compressor
.
template_name
(
'templates
\
photo
\
detail.jst'
,
'templates
\\
'
)
self
.
assertEqual
s
(
name
,
'photo_detail'
)
self
.
assertEqual
(
name
,
'photo_detail'
)
def
test_compile_templates
(
self
):
templates
=
self
.
compressor
.
compile_templates
([
_
(
'pipeline/templates/photo/list.jst'
)])
self
.
assertEqual
s
(
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
)
self
.
assertEqual
(
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'
)
...
...
@@ -95,16 +95,16 @@ class CompressorTest(TestCase):
def
test_construct_asset_path
(
self
):
asset_path
=
self
.
compressor
.
construct_asset_path
(
"../../images/sprite.png"
,
"css/plugins/gallery.css"
,
"css/gallery.css"
)
self
.
assertEqual
s
(
asset_path
,
"../images/sprite.png"
)
self
.
assertEqual
(
asset_path
,
"../images/sprite.png"
)
asset_path
=
self
.
compressor
.
construct_asset_path
(
"/images/sprite.png"
,
"css/plugins/gallery.css"
,
"css/gallery.css"
)
self
.
assertEqual
s
(
asset_path
,
"/images/sprite.png"
)
self
.
assertEqual
(
asset_path
,
"/images/sprite.png"
)
def
test_url_rewrite
(
self
):
output
=
self
.
compressor
.
concatenate_and_rewrite
([
_
(
'pipeline/css/urls.css'
),
],
'css/screen.css'
)
self
.
assertEqual
s
(
"""@font-face {
self
.
assertEqual
(
"""@font-face {
font-family: 'Pipeline';
src: url(../pipeline/fonts/pipeline.eot);
src: url(../pipeline/fonts/pipeline.eot?#iefix) format('embedded-opentype');
...
...
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