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
de2f52ca
Commit
de2f52ca
authored
Jan 07, 2015
by
John Eskew
Committed by
Zia Fazal
Apr 07, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle the correct exception to cause a 404 error upon asset not found
instead of a 500 error. Add 404 test.
parent
ebb0e497
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
2 deletions
+10
-2
cms/djangoapps/contentstore/tests/test_contentstore.py
+8
-1
common/djangoapps/contentserver/middleware.py
+2
-1
No files found.
cms/djangoapps/contentstore/tests/test_contentstore.py
View file @
de2f52ca
...
@@ -840,9 +840,16 @@ class MiscCourseTests(ContentStoreTestCase):
...
@@ -840,9 +840,16 @@ class MiscCourseTests(ContentStoreTestCase):
self
.
store
.
unpublish
(
self
.
chapter_loc
,
self
.
user
.
id
)
self
.
store
.
unpublish
(
self
.
chapter_loc
,
self
.
user
.
id
)
def
test_bad_contentstore_request
(
self
):
def
test_bad_contentstore_request
(
self
):
resp
=
self
.
client
.
get_html
(
'http://localhost:8001/c4x/CDX/123123/asset/&images_circuits_Lab7Solution2.png'
)
"""
Test that user get proper responses for urls with invalid url or
asset/course key
"""
resp
=
self
.
client
.
get_html
(
'/c4x/CDX/123123/asset/&invalid.png'
)
self
.
assertEqual
(
resp
.
status_code
,
400
)
self
.
assertEqual
(
resp
.
status_code
,
400
)
resp
=
self
.
client
.
get_html
(
'/c4x/CDX/123123/asset/invalid.png'
)
self
.
assertEqual
(
resp
.
status_code
,
404
)
def
test_delete_course
(
self
):
def
test_delete_course
(
self
):
"""
"""
This test creates a course, makes a draft item, and deletes the course. This will also assert that the
This test creates a course, makes a draft item, and deletes the course. This will also assert that the
...
...
common/djangoapps/contentserver/middleware.py
View file @
de2f52ca
...
@@ -15,6 +15,7 @@ from xmodule.modulestore import InvalidLocationError
...
@@ -15,6 +15,7 @@ from xmodule.modulestore import InvalidLocationError
from
opaque_keys
import
InvalidKeyError
from
opaque_keys
import
InvalidKeyError
from
opaque_keys.edx.locator
import
AssetLocator
from
opaque_keys.edx.locator
import
AssetLocator
from
cache_toolbox.core
import
get_cached_content
,
set_cached_content
from
cache_toolbox.core
import
get_cached_content
,
set_cached_content
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
from
xmodule.exceptions
import
NotFoundError
from
xmodule.exceptions
import
NotFoundError
# TODO: Soon as we have a reasonable way to serialize/deserialize AssetKeys, we need
# TODO: Soon as we have a reasonable way to serialize/deserialize AssetKeys, we need
...
@@ -44,7 +45,7 @@ class StaticContentServer(object):
...
@@ -44,7 +45,7 @@ class StaticContentServer(object):
# nope, not in cache, let's fetch from DB
# nope, not in cache, let's fetch from DB
try
:
try
:
content
=
AssetManager
.
find
(
loc
,
as_stream
=
True
)
content
=
AssetManager
.
find
(
loc
,
as_stream
=
True
)
except
NotFoundError
:
except
(
ItemNotFoundError
,
NotFoundError
)
:
response
=
HttpResponse
()
response
=
HttpResponse
()
response
.
status_code
=
404
response
.
status_code
=
404
return
response
return
response
...
...
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