Merge pull request #8520 from edx/ziafazal/SOL-978
remove in-memory files
This commit is contained in:
@@ -8,7 +8,6 @@ from PIL import Image
|
||||
import json
|
||||
|
||||
from django.conf import settings
|
||||
from django.test.utils import override_settings
|
||||
|
||||
from contentstore.tests.utils import CourseTestCase
|
||||
from contentstore.views import assets
|
||||
@@ -56,18 +55,19 @@ class AssetsTestCase(CourseTestCase):
|
||||
"""
|
||||
Returns an in-memory file of the specified type with the given name for testing
|
||||
"""
|
||||
sample_asset = BytesIO()
|
||||
sample_file_contents = "This file is generated by python unit test"
|
||||
if asset_type == 'text':
|
||||
sample_asset = BytesIO(name)
|
||||
sample_asset.name = '{name}.txt'.format(name=name)
|
||||
sample_asset.write(sample_file_contents)
|
||||
elif asset_type == 'image':
|
||||
image = Image.new("RGB", size=(50, 50), color=(256, 0, 0))
|
||||
sample_asset = BytesIO()
|
||||
image.save(unicode(sample_asset), 'jpeg')
|
||||
image.save(sample_asset, 'jpeg')
|
||||
sample_asset.name = '{name}.jpg'.format(name=name)
|
||||
sample_asset.seek(0)
|
||||
elif asset_type == 'opendoc':
|
||||
sample_asset = BytesIO(name)
|
||||
sample_asset.name = '{name}.odt'.format(name=name)
|
||||
sample_asset.write(sample_file_contents)
|
||||
sample_asset.seek(0)
|
||||
return sample_asset
|
||||
|
||||
|
||||
@@ -324,7 +324,7 @@ class DownloadTestCase(AssetsTestCase):
|
||||
# Now, download it.
|
||||
resp = self.client.get(self.uploaded_url, HTTP_ACCEPT='text/html')
|
||||
self.assertEquals(resp.status_code, 200)
|
||||
self.assertEquals(resp.content, self.asset_name)
|
||||
self.assertContains(resp, 'This file is generated by python unit test')
|
||||
|
||||
def test_download_not_found_throw(self):
|
||||
url = self.uploaded_url.replace(self.asset_name, 'not_the_asset_name')
|
||||
|
||||
Reference in New Issue
Block a user