From fb0ee690f226dc4be608ac20de28efff7a83637a Mon Sep 17 00:00:00 2001 From: David Baumgold Date: Tue, 19 Aug 2014 11:49:43 -0400 Subject: [PATCH] Cleaning up a few quality violations --- common/djangoapps/contentserver/middleware.py | 10 ++++++---- common/djangoapps/contentserver/tests/test.py | 14 ++++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/common/djangoapps/contentserver/middleware.py b/common/djangoapps/contentserver/middleware.py index 0bcfbe3819..d32470ea15 100644 --- a/common/djangoapps/contentserver/middleware.py +++ b/common/djangoapps/contentserver/middleware.py @@ -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: diff --git a/common/djangoapps/contentserver/tests/test.py b/common/djangoapps/contentserver/tests/test.py index 066551ac18..94d95d4d4a 100644 --- a/common/djangoapps/contentserver/tests/test.py +++ b/common/djangoapps/contentserver/tests/test.py @@ -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))