Use bytes with GridFS when not specifying an encoding - BOM-157

This commit is contained in:
Jeremy Bowman
2019-09-19 11:16:38 -04:00
parent cbf35593ac
commit fc57bf9763
2 changed files with 4 additions and 4 deletions

View File

@@ -40,7 +40,7 @@ class DeleteCourseTests(ModuleStoreTestCase):
store = contentstore()
asset_key = course_run.id.make_asset_key('asset', 'test.txt')
content = StaticContent(asset_key, 'test.txt', 'plain/text', 'test data')
content = StaticContent(asset_key, 'test.txt', 'plain/text', b'test data')
store.save(content)
__, asset_count = store.get_all_content_for_course(course_run.id)
assert asset_count == 1
@@ -69,7 +69,7 @@ class DeleteCourseTests(ModuleStoreTestCase):
store = contentstore()
asset_key = course_run.id.make_asset_key('asset', 'test.txt')
content = StaticContent(asset_key, 'test.txt', 'plain/text', 'test data')
content = StaticContent(asset_key, 'test.txt', 'plain/text', b'test data')
store.save(content)
__, asset_count = store.get_all_content_for_course(course_run.id)
assert asset_count == 1

View File

@@ -1310,7 +1310,7 @@ class TestEditorSavedMethod(BaseTestVideoXBlock):
self.MODULESTORE = MODULESTORES[default_store] # pylint: disable=invalid-name
self.initialize_block(metadata=self.metadata)
item = self.store.get_item(self.item_descriptor.location)
with open(self.file_path, "r") as myfile:
with open(self.file_path, "rb") as myfile:
save_to_store(myfile.read(), self.file_name, 'text/sjson', item.location)
item.sub = "3_yD_cEKoCk"
# subs_video.srt.sjson does not exist before calling editor_saved function
@@ -1330,7 +1330,7 @@ class TestEditorSavedMethod(BaseTestVideoXBlock):
self.MODULESTORE = MODULESTORES[default_store]
self.initialize_block(metadata=self.metadata)
item = self.store.get_item(self.item_descriptor.location)
with open(self.file_path, "r") as myfile:
with open(self.file_path, "rb") as myfile:
save_to_store(myfile.read(), self.file_name, 'text/sjson', item.location)
save_to_store(myfile.read(), 'subs_video.srt.sjson', 'text/sjson', item.location)
item.sub = "3_yD_cEKoCk"