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
cd14104f
Commit
cd14104f
authored
Jan 02, 2016
by
Timothée Peignier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve tests
parent
b68d46e7
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
39 deletions
+42
-39
tests/tests/test_compressor.py
+21
-17
tests/tests/test_glob.py
+21
-22
tests/tests/test_template.py
+0
-0
No files found.
tests/tests/test_compressor.py
View file @
cd14104f
...
...
@@ -2,14 +2,17 @@
from
__future__
import
unicode_literals
import
base64
import
os
import
io
import
os
import
sys
try
:
from
mock
import
patch
except
ImportError
:
from
unittest.mock
import
patch
# noqa
from
unittest
import
skipIf
from
django.test
import
TestCase
from
pipeline.compressors
import
Compressor
,
TEMPLATE_FUNC
,
\
...
...
@@ -74,32 +77,32 @@ class CompressorTest(TestCase):
self
.
assertEqual
(
base_path
,
_
(
'js/templates'
))
def
test_absolute_path
(
self
):
absolute_path
=
self
.
compressor
.
absolute_path
(
'../../images/sprite.png'
,
'css/plugins/'
)
absolute_path
=
self
.
compressor
.
absolute_path
(
'
../../images/sprite.png'
,
'
css/plugins/'
)
self
.
assertEqual
(
absolute_path
,
'images/sprite.png'
)
absolute_path
=
self
.
compressor
.
absolute_path
(
'/images/sprite.png'
,
'css/plugins/'
)
absolute_path
=
self
.
compressor
.
absolute_path
(
'
/images/sprite.png'
,
'
css/plugins/'
)
self
.
assertEqual
(
absolute_path
,
'/images/sprite.png'
)
def
test_template_name
(
self
):
name
=
self
.
compressor
.
template_name
(
'templates/photo/detail.jst'
,
'templates/'
)
name
=
self
.
compressor
.
template_name
(
'templates/
photo/detail.jst'
,
'templates/
'
)
self
.
assertEqual
(
name
,
'photo_detail'
)
name
=
self
.
compressor
.
template_name
(
'templates/photo_edit.jst'
,
''
)
self
.
assertEqual
(
name
,
'photo_edit'
)
name
=
self
.
compressor
.
template_name
(
'templates
\
photo
\
detail.jst'
,
'templates
\\
'
)
name
=
self
.
compressor
.
template_name
(
'templates
\
photo
\
detail.jst'
,
'templates
\
\
'
)
self
.
assertEqual
(
name
,
'photo_detail'
)
@pipeline_settings
(
TEMPLATE_SEPARATOR
=
'/'
)
def
test_template_name_separator
(
self
):
name
=
self
.
compressor
.
template_name
(
'templates/photo/detail.jst'
,
'templates/'
)
name
=
self
.
compressor
.
template_name
(
'templates/
photo/detail.jst'
,
'templates/
'
)
self
.
assertEqual
(
name
,
'photo/detail'
)
name
=
self
.
compressor
.
template_name
(
'templates/photo_edit.jst'
,
''
)
self
.
assertEqual
(
name
,
'photo_edit'
)
name
=
self
.
compressor
.
template_name
(
'templates
\
photo
\
detail.jst'
,
'templates
\\
'
)
name
=
self
.
compressor
.
template_name
(
'templates
\
photo
\
detail.jst'
,
'templates
\
\
'
)
self
.
assertEqual
(
name
,
'photo/detail'
)
def
test_compile_templates
(
self
):
...
...
@@ -118,11 +121,11 @@ class CompressorTest(TestCase):
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"
,
"css/plugins/gallery.css"
,
"css/gallery.css"
)
asset_path
=
self
.
compressor
.
construct_asset_path
(
"
../../images/sprite.png"
,
"
css/plugins/gallery.css"
,
"css/gallery.css"
)
self
.
assertEqual
(
asset_path
,
"../images/sprite.png"
)
asset_path
=
self
.
compressor
.
construct_asset_path
(
"/images/sprite.png"
,
"css/plugins/gallery.css"
,
"css/gallery.css"
)
asset_path
=
self
.
compressor
.
construct_asset_path
(
"
/images/sprite.png"
,
"
css/plugins/gallery.css"
,
"css/gallery.css"
)
self
.
assertEqual
(
asset_path
,
"/images/sprite.png"
)
def
test_url_rewrite
(
self
):
...
...
@@ -170,6 +173,7 @@ class CompressorTest(TestCase):
}
"""
,
output
)
@skipIf
(
sys
.
platform
.
startswith
(
"win"
),
"requires posix platform"
)
def
test_compressor_subprocess_unicode
(
self
):
path
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
__file__
))
content
=
io
.
open
(
path
+
'/assets/css/unicode.css'
,
encoding
=
"utf-8"
)
.
read
()
...
...
tests/tests/test_glob.py
View file @
cd14104f
...
...
@@ -52,46 +52,45 @@ class GlobTest(TestCase):
glob
.
staticfiles_storage
=
self
.
old_storage
def
test_glob_literal
(
self
):
self
.
assertSequenceEqual
(
self
.
glob
(
'a'
),
[
self
.
normpath
(
'a'
)])
self
.
assertSequenceEqual
(
self
.
glob
(
'a'
,
'D'
),
[
self
.
normpath
(
'a'
,
'D'
)])
self
.
assertSequenceEqual
(
self
.
glob
(
'aab'
),
[
self
.
normpath
(
'aab'
)])
self
.
assertSequenceEqual
(
self
.
glob
(
'a'
),
[
self
.
normpath
(
'a'
)])
self
.
assertSequenceEqual
(
self
.
glob
(
'a'
,
'D'
),
[
self
.
normpath
(
'a'
,
'D'
)])
self
.
assertSequenceEqual
(
self
.
glob
(
'aab'
),
[
self
.
normpath
(
'aab'
)])
self
.
assertSequenceEqual
(
self
.
glob
(
'zymurgy'
),
[])
def
test_glob_one_directory
(
self
):
self
.
assertSequenceEqual
(
self
.
glob
(
'a*'
),
map
(
self
.
normpath
,
[
'a'
,
'aab'
,
'aaa'
]))
self
.
assertSequenceEqual
(
self
.
glob
(
'*a'
),
map
(
self
.
normpath
,
[
'a'
,
'aaa'
]))
self
.
assertSequenceEqual
(
self
.
glob
(
'aa?'
),
map
(
self
.
normpath
,
[
'aaa'
,
'aab'
]))
self
.
assertSequenceEqual
(
self
.
glob
(
'aa[ab]'
),
map
(
self
.
normpath
,
[
'aaa'
,
'aab'
]))
self
.
assertSequenceEqual
(
self
.
glob
(
'a*'
),
map
(
self
.
normpath
,
[
'a'
,
'aab'
,
'aaa'
]))
self
.
assertSequenceEqual
(
self
.
glob
(
'*a'
),
map
(
self
.
normpath
,
[
'a'
,
'aaa'
]))
self
.
assertSequenceEqual
(
self
.
glob
(
'aa?'
),
map
(
self
.
normpath
,
[
'aaa'
,
'aab'
]))
self
.
assertSequenceEqual
(
self
.
glob
(
'aa[ab]'
),
map
(
self
.
normpath
,
[
'aaa'
,
'aab'
]))
self
.
assertSequenceEqual
(
self
.
glob
(
'*q'
),
[])
def
test_glob_nested_directory
(
self
):
if
os
.
path
.
normcase
(
"abCD"
)
==
"abCD"
:
# case-sensitive filesystem
self
.
assertSequenceEqual
(
self
.
glob
(
'a'
,
'bcd'
,
'E*'
),
[
self
.
normpath
(
'a'
,
'bcd'
,
'EF'
)])
self
.
assertSequenceEqual
(
self
.
glob
(
'a'
,
'bcd'
,
'E*'
),
[
self
.
normpath
(
'a'
,
'bcd'
,
'EF'
)])
else
:
# case insensitive filesystem
self
.
assertSequenceEqual
(
self
.
glob
(
'a'
,
'bcd'
,
'E*'
),
[
self
.
normpath
(
'a'
,
'bcd'
,
'EF'
),
self
.
normpath
(
'a'
,
'bcd'
,
'efg'
)
])
self
.
assertSequenceEqual
(
self
.
glob
(
'a'
,
'bcd'
,
'*g'
),
[
self
.
normpath
(
'a'
,
'bcd'
,
'efg'
)])
self
.
assertSequenceEqual
(
self
.
glob
(
'a'
,
'bcd'
,
'*g'
),
[
self
.
normpath
(
'a'
,
'bcd'
,
'efg'
)])
def
test_glob_directory_names
(
self
):
self
.
assertSequenceEqual
(
self
.
glob
(
'*'
,
'D'
),
[
self
.
normpath
(
'a'
,
'D'
)])
self
.
assertSequenceEqual
(
self
.
glob
(
'*'
,
'D'
),
[
self
.
normpath
(
'a'
,
'D'
)])
self
.
assertSequenceEqual
(
self
.
glob
(
'*'
,
'*a'
),
[])
self
.
assertSequenceEqual
(
self
.
glob
(
'a'
,
'*'
,
'*'
,
'*a'
),
self
.
assertSequenceEqual
(
self
.
glob
(
'a'
,
'*'
,
'*'
,
'*a'
),
[
self
.
normpath
(
'a'
,
'bcd'
,
'efg'
,
'ha'
)])
self
.
assertSequenceEqual
(
self
.
glob
(
'?a?'
,
'*F'
),
self
.
assertSequenceEqual
(
self
.
glob
(
'?a?'
,
'*F'
),
map
(
self
.
normpath
,
[
os
.
path
.
join
(
'aaa'
,
'zzzF'
),
os
.
path
.
join
(
'aab'
,
'F'
)]))
...
...
tests/tests/test_template.py
View file @
cd14104f
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