Skip to content
Snippets Groups Projects
Unverified Commit 18cf3709 authored by Awais Qureshi's avatar Awais Qureshi Committed by GitHub
Browse files

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

BOM-364
parents aff9aca9 6b50e12b
No related branches found
Tags release-2021-09-20-11.22
No related merge requests found
......@@ -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)
......
......@@ -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(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment