Skip to content
Snippets Groups Projects
Commit 86c7b9f8 authored by aarif's avatar aarif
Browse files

updated the division operation to make the output compatible in python 2 and python 3

changes made to fix quality errors

changes made to fix issues on BOM-587

minor changes made to fix quality issues

minor changes

removed unused pylint supression
parent 6e13e061
No related merge requests found
......@@ -156,7 +156,7 @@ class StaticContentServer(object):
if 0 <= first <= last < content.length:
# If the byte range is satisfiable
response = HttpResponse(content.stream_data_in_range(first, last))
response['Content-Range'] = b'bytes {first}-{last}/{length}'.format(
response['Content-Range'] = u'bytes {first}-{last}/{length}'.format(
first=first, last=last, length=content.length
)
response['Content-Length'] = str(last - first + 1)
......
......@@ -218,13 +218,8 @@ class ContentStoreToyCourseTest(SharedModuleStoreTestCase):
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'],
b'bytes {first}-{last}/{length}'.format(
first=0, last=self.length_unlocked - 1,
length=self.length_unlocked
)
)
self.assertEqual(resp['Content-Range'], u'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))
def test_range_request_partial_file(self):
......@@ -233,13 +228,13 @@ class ContentStoreToyCourseTest(SharedModuleStoreTestCase):
outputs partial content status code and valid Content-Range and Content-Length.
first_byte and last_byte are chosen to be simple but non trivial values.
"""
first_byte = self.length_unlocked / 4
last_byte = self.length_unlocked / 2
first_byte = self.length_unlocked // 4
last_byte = self.length_unlocked // 2
resp = self.client.get(self.url_unlocked, HTTP_RANGE='bytes={first}-{last}'.format(
first=first_byte, last=last_byte))
self.assertEqual(resp.status_code, 206) # HTTP_206_PARTIAL_CONTENT
self.assertEqual(resp['Content-Range'], b'bytes {first}-{last}/{length}'.format(
self.assertEqual(resp['Content-Range'], u'bytes {first}-{last}/{length}'.format(
first=first_byte, last=last_byte, length=self.length_unlocked))
self.assertEqual(resp['Content-Length'], str(last_byte - first_byte + 1))
......
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