Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
e9f2f626
Commit
e9f2f626
authored
10 years ago
by
cahrens
Browse files
Options
Downloads
Patches
Plain Diff
Change to work with split modulestore.
make_asset_key does not start with "/" for split locators.
parent
7a3a48b1
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cms/djangoapps/contentstore/tests/test_utils.py
+18
-8
18 additions, 8 deletions
cms/djangoapps/contentstore/tests/test_utils.py
with
18 additions
and
8 deletions
cms/djangoapps/contentstore/tests/test_utils.py
+
18
−
8
View file @
e9f2f626
...
...
@@ -168,28 +168,38 @@ class ExtraPanelTabTestCase(TestCase):
class
CourseImageTestCase
(
ModuleStoreTestCase
):
"""
Tests for course image URLs.
"""
def
verify_url
(
self
,
expected_url
,
actual_url
):
"""
Helper method for verifying the URL is as expected.
"""
if
not
expected_url
.
startswith
(
"
/
"
):
expected_url
=
"
/
"
+
expected_url
self
.
assertEquals
(
expected_url
,
actual_url
)
def
test_get_image_url
(
self
):
"""
Test image URL formatting.
"""
course
=
CourseFactory
.
create
()
url
=
utils
.
course_image_url
(
course
)
self
.
assertEquals
(
url
,
unicode
(
course
.
id
.
make_asset_key
(
'
asset
'
,
course
.
course_image
)))
self
.
verify_url
(
unicode
(
course
.
id
.
make_asset_key
(
'
asset
'
,
course
.
course_image
)),
utils
.
course_image_url
(
course
)
)
def
test_non_ascii_image_name
(
self
):
"""
Verify that non-ascii image names are cleaned
"""
course_image
=
u
'
before_
\N{SNOWMAN}
_after.jpg
'
course
=
CourseFactory
.
create
(
course_image
=
course_image
)
self
.
assertEquals
(
u
tils
.
course_image_url
(
course
),
u
nicode
(
course
.
id
.
ma
k
e_
asset_key
(
'
asset
'
,
course_image
.
replace
(
u
'
\N{SNOWMAN}
'
,
'
_
'
))
)
self
.
verify_url
(
u
nicode
(
course
.
id
.
make_asset_key
(
'
asset
'
,
course_image
.
replace
(
u
'
\N{SNOWMAN}
'
,
'
_
'
))
),
u
tils
.
course
_i
ma
g
e_
url
(
course
)
)
def
test_spaces_in_image_name
(
self
):
"""
Verify that image names with spaces in them are cleaned
"""
course_image
=
u
'
before after.jpg
'
course
=
CourseFactory
.
create
(
course_image
=
u
'
before after.jpg
'
)
self
.
assertEquals
(
u
tils
.
course_image_url
(
course
),
u
nicode
(
course
.
id
.
make_asset_key
(
'
asset
'
,
course_image
.
replace
(
"
"
,
"
_
"
))
)
self
.
verify_url
(
u
nicode
(
course
.
id
.
make_asset_key
(
'
asset
'
,
course_image
.
replace
(
"
"
,
"
_
"
))
),
u
tils
.
course_image_url
(
course
)
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment