Merge pull request #21553 from edx/awais786/BOM-364

BOM-364
This commit is contained in:
Awais Qureshi
2019-09-05 09:47:12 +05:00
committed by GitHub
2 changed files with 6 additions and 2 deletions

View File

@@ -1350,6 +1350,8 @@ def validate_textbooks_json(text):
"""
Validate the given text as representing a single PDF textbook
"""
if isinstance(text, (bytes, bytearray)): # data appears as bytes
text = text.decode('utf-8')
try:
textbooks = json.loads(text)
except ValueError:
@@ -1370,6 +1372,8 @@ def validate_textbook_json(textbook):
"""
Validate the given text as representing a list of PDF textbooks
"""
if isinstance(textbook, (bytes, bytearray)): # data appears as bytes
textbook = textbook.decode('utf-8')
if isinstance(textbook, six.string_types):
try:
textbook = json.loads(textbook)

View File

@@ -258,7 +258,7 @@ class TextbookDetailTestCase(CourseTestCase):
self.assertEqual(resp.status_code, 201)
resp2 = self.client.get(url)
self.assertEqual(resp2.status_code, 200)
compare = json.loads(resp2.content)
compare = json.loads(resp2.content.decode('utf-8'))
self.assertEqual(compare, textbook)
self.reload_course()
self.assertEqual(
@@ -281,7 +281,7 @@ class TextbookDetailTestCase(CourseTestCase):
self.assertEqual(resp.status_code, 201)
resp2 = self.client.get(self.url2)
self.assertEqual(resp2.status_code, 200)
compare = json.loads(resp2.content)
compare = json.loads(resp2.content.decode('utf-8'))
self.assertEqual(compare, replacement)
course = self.store.get_item(self.course.location)
self.assertEqual(