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
fabeffa8
Commit
fabeffa8
authored
Jun 20, 2011
by
Timothée Peignier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test versioning class and fix some logic too
parent
8f58c719
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
6 deletions
+75
-6
pipeline/versioning/__init__.py
+5
-5
tests/static/css/master.123456.css
+0
-0
tests/tests/versioning.py
+70
-1
No files found.
pipeline/versioning/__init__.py
View file @
fabeffa8
...
@@ -10,12 +10,12 @@ class Versioning(object):
...
@@ -10,12 +10,12 @@ class Versioning(object):
def
__init__
(
self
,
verbose
=
False
):
def
__init__
(
self
,
verbose
=
False
):
self
.
verbose
=
verbose
self
.
verbose
=
verbose
def
version
n
er
(
self
):
def
versioner
(
self
):
return
to_class
(
settings
.
PIPELINE_VERSIONING
)(
self
)
return
to_class
(
settings
.
PIPELINE_VERSIONING
)(
self
)
version
ner
=
property
(
version
ner
)
version
er
=
property
(
versio
ner
)
def
version
(
self
,
paths
):
def
version
(
self
,
paths
):
return
getattr
(
self
.
version
n
er
,
'version'
)(
paths
)
return
getattr
(
self
.
versioner
,
'version'
)(
paths
)
def
version_from_file
(
self
,
path
,
filename
):
def
version_from_file
(
self
,
path
,
filename
):
filename
=
settings
.
PIPELINE_VERSION_PLACEHOLDER
.
join
([
re
.
escape
(
part
)
for
part
in
filename
.
split
(
settings
.
PIPELINE_VERSION_PLACEHOLDER
)])
filename
=
settings
.
PIPELINE_VERSION_PLACEHOLDER
.
join
([
re
.
escape
(
part
)
for
part
in
filename
.
split
(
settings
.
PIPELINE_VERSION_PLACEHOLDER
)])
...
@@ -41,10 +41,10 @@ class Versioning(object):
...
@@ -41,10 +41,10 @@ class Versioning(object):
output_file
=
self
.
output_filename
(
output_file
,
version
)
output_file
=
self
.
output_filename
(
output_file
,
version
)
if
not
storage
.
exists
(
output_file
):
if
not
storage
.
exists
(
output_file
):
return
True
,
version
return
True
,
version
return
getattr
(
self
.
version
n
er
,
'need_update'
)(
output_file
,
paths
,
version
)
return
getattr
(
self
.
versioner
,
'need_update'
)(
output_file
,
paths
,
version
)
def
cleanup
(
self
,
filename
):
def
cleanup
(
self
,
filename
):
if
not
settings
.
PIPELINE_VERSION
and
not
settings
.
PIPELINE_VERSION_REMOVE_OLD
:
if
not
(
settings
.
PIPELINE_VERSION
and
settings
.
PIPELINE_VERSION_REMOVE_OLD
)
:
return
# Nothing to delete here
return
# Nothing to delete here
path
=
os
.
path
.
dirname
(
filename
)
path
=
os
.
path
.
dirname
(
filename
)
filename
=
settings
.
PIPELINE_VERSION_PLACEHOLDER
.
join
([
re
.
escape
(
part
)
for
part
in
filename
.
split
(
settings
.
PIPELINE_VERSION_PLACEHOLDER
)])
filename
=
settings
.
PIPELINE_VERSION_PLACEHOLDER
.
join
([
re
.
escape
(
part
)
for
part
in
filename
.
split
(
settings
.
PIPELINE_VERSION_PLACEHOLDER
)])
...
...
tests/static/css/master.123456.css
0 → 100644
View file @
fabeffa8
tests/tests/versioning.py
View file @
fabeffa8
from
mock
import
patch
from
django.test
import
TestCase
from
django.test
import
TestCase
from
pipeline.conf
import
settings
from
pipeline.storage
import
storage
from
pipeline.versioning
import
Versioning
from
pipeline.versioning.mtime
import
MTimeVersioning
class
VersioningTest
(
TestCase
):
class
VersioningTest
(
TestCase
):
pass
def
setUp
(
self
):
self
.
versioning
=
Versioning
()
self
.
old_pipeline_version
=
settings
.
PIPELINE_VERSION
def
test_versioner_class
(
self
):
self
.
assertTrue
(
isinstance
(
self
.
versioning
.
versioner
,
MTimeVersioning
))
def
test_output_filename
(
self
):
output_filename
=
self
.
versioning
.
output_filename
(
"css/master.?.css"
,
"1308127956"
)
self
.
assertEquals
(
output_filename
,
'css/master.0.css'
)
def
test_output_filename_with_version
(
self
):
settings
.
PIPELINE_VERSION
=
True
output_filename
=
self
.
versioning
.
output_filename
(
"css/master.?.css"
,
"1308127956"
)
self
.
assertEquals
(
output_filename
,
'css/master.1308127956.css'
)
@patch.object
(
MTimeVersioning
,
'version'
)
def
test_need_update
(
self
,
mock
):
mock
.
return_value
=
"1307480052"
need_update
,
version
=
self
.
versioning
.
need_update
(
'css/master.1308127956.css'
,
[
'css/first.css'
],
)
self
.
assertEquals
(
need_update
,
True
)
self
.
assertEquals
(
version
,
"1307480052"
)
@patch.object
(
MTimeVersioning
,
'need_update'
)
def
test_no_update
(
self
,
mock
):
mock
.
return_value
=
(
False
,
"123456"
)
need_update
,
version
=
self
.
versioning
.
need_update
(
'css/master.123456.css'
,
[
'css/first.css'
],
)
self
.
assertTrue
(
mock
.
called
)
self
.
assertEquals
(
need_update
,
False
)
self
.
assertEquals
(
version
,
"123456"
)
@patch.object
(
MTimeVersioning
,
'version'
)
def
test_version
(
self
,
mock
):
mock
.
return_value
=
"123456"
version
=
self
.
versioning
.
version
([
'css/first.css'
])
self
.
assertTrue
(
mock
.
called
)
self
.
assertEquals
(
version
,
"123456"
)
def
test_version_from_file
(
self
):
settings
.
PIPELINE_VERSION
=
True
version
=
self
.
versioning
.
version_from_file
(
'css/'
,
"master.?.css"
)
self
.
assertEquals
(
version
,
"123456"
)
@patch.object
(
storage
,
'exists'
)
def
test_no_cleanup
(
self
,
mock
):
self
.
versioning
.
cleanup
(
'css/master.?.css'
)
self
.
assertFalse
(
mock
.
called
)
@patch.object
(
storage
,
'delete'
)
def
test_cleanup
(
self
,
mock
):
settings
.
PIPELINE_VERSION
=
True
self
.
versioning
.
cleanup
(
'css/master.?.css'
)
mock
.
assert_called_with
(
'css/master.123456.css'
)
def
tearDown
(
self
):
settings
.
PIPELINE_VERSION
=
self
.
old_pipeline_version
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