From ed434c55d1c209d8d5d0a168e30828eaf11f1db5 Mon Sep 17 00:00:00 2001 From: Zia Fazal Date: Mon, 15 Jun 2015 15:26:07 +0500 Subject: [PATCH] remove in-memory files no need to create zero by in memory images added contents to test upload files --- .../contentstore/views/tests/test_assets.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cms/djangoapps/contentstore/views/tests/test_assets.py b/cms/djangoapps/contentstore/views/tests/test_assets.py index 9bd55c9d50..3fc5646ac7 100644 --- a/cms/djangoapps/contentstore/views/tests/test_assets.py +++ b/cms/djangoapps/contentstore/views/tests/test_assets.py @@ -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')