@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user