Cleaning up a few quality violations
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from django.http import (HttpResponse, HttpResponseNotModified,
|
||||
HttpResponseForbidden)
|
||||
from django.http import (
|
||||
HttpResponse, HttpResponseNotModified, HttpResponseForbidden
|
||||
)
|
||||
from student.models import CourseEnrollment
|
||||
|
||||
from xmodule.contentstore.django import contentstore
|
||||
@@ -13,6 +14,7 @@ from xmodule.exceptions import NotFoundError
|
||||
# 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
|
||||
|
||||
|
||||
class StaticContentServer(object):
|
||||
def process_request(self, request):
|
||||
# look to see if the request is prefixed with an asset prefix tag
|
||||
@@ -113,11 +115,11 @@ class StaticContentServer(object):
|
||||
first=first, last=last, length=content.length
|
||||
)
|
||||
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:
|
||||
# Malformed Range attribute
|
||||
response = HttpResponse()
|
||||
response.status_code = 400 # HTTP_400_BAD_REQUEST
|
||||
response.status_code = 400 # HTTP_400_BAD_REQUEST
|
||||
return response
|
||||
|
||||
else:
|
||||
|
||||
@@ -42,8 +42,10 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
|
||||
|
||||
self.course_key = SlashSeparatedCourseKey('edX', 'toy', '2012_Fall')
|
||||
|
||||
import_from_xml(modulestore(), self.user.id, 'common/test/data/', ['toy'],
|
||||
static_content_store=self.contentstore, verbose=True)
|
||||
import_from_xml(
|
||||
modulestore(), self.user.id, 'common/test/data/', ['toy'],
|
||||
static_content_store=self.contentstore, verbose=True
|
||||
)
|
||||
|
||||
# A locked asset
|
||||
self.locked_asset = self.course_key.make_asset_key('asset', 'sample_static.txt')
|
||||
@@ -109,8 +111,12 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
|
||||
resp = self.client.get(self.url_unlocked, HTTP_RANGE='bytes=0-')
|
||||
|
||||
self.assertEqual(resp.status_code, 206) # HTTP_206_PARTIAL_CONTENT
|
||||
self.assertEqual(resp['Content-Range'], 'bytes {first}-{last}/{length}'.format(
|
||||
first=0, last=self.length_unlocked-1, length=self.length_unlocked)
|
||||
self.assertEqual(
|
||||
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))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user