Commit ed434c55 by Zia Fazal

remove in-memory files

no need to create zero by in memory images

added contents to test upload files
parent 710c2110
......@@ -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')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment