Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
edx
edx-platform
Commits
18f3221d
Commit
18f3221d
authored
Jan 08, 2015
by
Waheed Ahmed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enforced '000' prefix for xmodule.js and added unit test.
TNL-1070
parent
30b572b1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
5 deletions
+20
-5
common/lib/xmodule/xmodule/static_content.py
+3
-1
common/lib/xmodule/xmodule/tests/test_content.py
+15
-0
common/lib/xmodule/xmodule/x_module.py
+2
-4
No files found.
common/lib/xmodule/xmodule/static_content.py
View file @
18f3221d
...
...
@@ -122,9 +122,11 @@ def _write_js(output_root, classes):
js_fragments
=
set
()
for
class_
in
classes
:
module_js
=
class_
.
get_javascript
()
# It will enforce 000 prefix for xmodule.js.
js_fragments
.
add
((
0
,
'js'
,
module_js
.
get
(
'xmodule_js'
)))
for
filetype
in
(
'coffee'
,
'js'
):
for
idx
,
fragment
in
enumerate
(
module_js
.
get
(
filetype
,
[])):
js_fragments
.
add
((
idx
,
filetype
,
fragment
))
js_fragments
.
add
((
idx
+
1
,
filetype
,
fragment
))
for
idx
,
filetype
,
fragment
in
sorted
(
js_fragments
):
filename
=
"{idx:0=3d}-{hash}.{type}"
.
format
(
...
...
common/lib/xmodule/xmodule/tests/test_content.py
View file @
18f3221d
"""Tests for contents"""
import
os
import
unittest
import
ddt
from
path
import
path
from
xmodule.contentstore.content
import
StaticContent
,
StaticContentStream
from
xmodule.contentstore.content
import
ContentStore
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
,
AssetLocation
from
xmodule.static_content
import
_write_js
,
_list_descriptors
SAMPLE_STRING
=
"""
This is a sample string with more than 1024 bytes, the default STREAM_DATA_CHUNK_SIZE
...
...
@@ -155,3 +160,13 @@ class ContentTest(unittest.TestCase):
total_length
+=
len
(
chunck
)
self
.
assertEqual
(
total_length
,
last_byte
-
first_byte
+
1
)
def
test_static_content_write_js
(
self
):
"""
Test that only one filename starts with 000.
"""
output_root
=
path
(
u'common/static/xmodule/descriptors/js'
)
js_file_paths
=
_write_js
(
output_root
,
_list_descriptors
())
js_file_paths
=
[
file_path
for
file_path
in
js_file_paths
if
os
.
path
.
basename
(
file_path
)
.
startswith
(
'000-'
)]
self
.
assertEqual
(
len
(
js_file_paths
),
1
)
self
.
assertIn
(
"XModule.Descriptor = (function () {"
,
open
(
js_file_paths
[
0
])
.
read
())
common/lib/xmodule/xmodule/x_module.py
View file @
18f3221d
...
...
@@ -200,10 +200,8 @@ class HTMLSnippet(object):
coffee
=
cls
.
js
.
setdefault
(
'coffee'
,
[])
js
=
cls
.
js
.
setdefault
(
'js'
,
[])
fragment
=
resource_string
(
__name__
,
'js/src/xmodule.js'
)
if
fragment
not
in
js
:
js
.
insert
(
0
,
fragment
)
# Added xmodule.js separately to enforce 000 prefix for this only.
cls
.
js
.
setdefault
(
'xmodule_js'
,
resource_string
(
__name__
,
'js/src/xmodule.js'
))
return
cls
.
js
...
...
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