Commit b4d14a56 by David Baumgold

Merge pull request #4892 from edx/db/marcnu-quality

Cleaning up a few quality violations
parents 0a8cd53d fb0ee690
from django.http import (HttpResponse, HttpResponseNotModified, from django.http import (
HttpResponseForbidden) HttpResponse, HttpResponseNotModified, HttpResponseForbidden
)
from student.models import CourseEnrollment from student.models import CourseEnrollment
from xmodule.contentstore.django import contentstore from xmodule.contentstore.django import contentstore
...@@ -13,6 +14,7 @@ from xmodule.exceptions import NotFoundError ...@@ -13,6 +14,7 @@ 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
# to change this file so instead of using course_id_partial, we're just using asset keys # to change this file so instead of using course_id_partial, we're just using asset keys
class StaticContentServer(object): class StaticContentServer(object):
def process_request(self, request): def process_request(self, request):
# look to see if the request is prefixed with an asset prefix tag # look to see if the request is prefixed with an asset prefix tag
...@@ -113,11 +115,11 @@ class StaticContentServer(object): ...@@ -113,11 +115,11 @@ class StaticContentServer(object):
first=first, last=last, length=content.length first=first, last=last, length=content.length
) )
response['Content-Length'] = str(last - first + 1) response['Content-Length'] = str(last - first + 1)
response.status_code = 206 # HTTP_206_PARTIAL_CONTENT response.status_code = 206 # HTTP_206_PARTIAL_CONTENT
if not response: if not response:
# Malformed Range attribute # Malformed Range attribute
response = HttpResponse() response = HttpResponse()
response.status_code = 400 # HTTP_400_BAD_REQUEST response.status_code = 400 # HTTP_400_BAD_REQUEST
return response return response
else: else:
......
...@@ -42,8 +42,10 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase): ...@@ -42,8 +42,10 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
self.course_key = SlashSeparatedCourseKey('edX', 'toy', '2012_Fall') self.course_key = SlashSeparatedCourseKey('edX', 'toy', '2012_Fall')
import_from_xml(modulestore(), self.user.id, 'common/test/data/', ['toy'], import_from_xml(
static_content_store=self.contentstore, verbose=True) modulestore(), self.user.id, 'common/test/data/', ['toy'],
static_content_store=self.contentstore, verbose=True
)
# A locked asset # A locked asset
self.locked_asset = self.course_key.make_asset_key('asset', 'sample_static.txt') self.locked_asset = self.course_key.make_asset_key('asset', 'sample_static.txt')
...@@ -109,8 +111,12 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase): ...@@ -109,8 +111,12 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
resp = self.client.get(self.url_unlocked, HTTP_RANGE='bytes=0-') resp = self.client.get(self.url_unlocked, HTTP_RANGE='bytes=0-')
self.assertEqual(resp.status_code, 206) # HTTP_206_PARTIAL_CONTENT self.assertEqual(resp.status_code, 206) # HTTP_206_PARTIAL_CONTENT
self.assertEqual(resp['Content-Range'], 'bytes {first}-{last}/{length}'.format( self.assertEqual(
first=0, last=self.length_unlocked-1, length=self.length_unlocked) resp['Content-Range'],
'bytes {first}-{last}/{length}'.format(
first=0, last=self.length_unlocked - 1,
length=self.length_unlocked
)
) )
self.assertEqual(resp['Content-Length'], str(self.length_unlocked)) self.assertEqual(resp['Content-Length'], str(self.length_unlocked))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment