diff --git a/cms/djangoapps/contentstore/views/tests/test_assets.py b/cms/djangoapps/contentstore/views/tests/test_assets.py index 6ee861888809..a4ca99a67b08 100644 --- a/cms/djangoapps/contentstore/views/tests/test_assets.py +++ b/cms/djangoapps/contentstore/views/tests/test_assets.py @@ -26,6 +26,7 @@ from xmodule.contentstore.django import contentstore # lint-amnesty, pylint: disable=wrong-import-order from xmodule.modulestore import ModuleStoreEnum # lint-amnesty, pylint: disable=wrong-import-order from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=wrong-import-order +from xmodule.modulestore.tests.factories import CourseFactory from xmodule.modulestore.xml_importer import import_course_from_xml # lint-amnesty, pylint: disable=wrong-import-order TEST_DATA_DIR = settings.COMMON_TEST_DATA_ROOT @@ -43,6 +44,7 @@ class AssetsTestCase(CourseTestCase): """ def setUp(self): super().setUp() + self.course = CourseFactory(default_store='split') self.url = reverse_course_url('assets_handler', self.course.id) def upload_asset(self, name="asset-1", asset_type='text'): @@ -513,15 +515,15 @@ def setUp(self): response = self.client.post(self.url, {"name": self.asset_name, "file": self.asset}) self.assertEqual(response.status_code, 200) - self.uploaded_url = json.loads(response.content.decode('utf-8'))['asset']['url'] + self.uploaded_id = json.loads(response.content.decode('utf-8'))['asset']['id'] - self.asset_location = AssetKey.from_string(self.uploaded_url) + self.asset_location = AssetKey.from_string(self.uploaded_id) self.content = contentstore().find(self.asset_location) def test_delete_asset(self): """ Tests the happy path :) """ test_url = reverse_course_url( - 'assets_handler', self.course.id, kwargs={'asset_key_string': str(self.uploaded_url)}) + 'assets_handler', self.course.id, kwargs={'asset_key_string': self.uploaded_id}) resp = self.client.delete(test_url, HTTP_ACCEPT="application/json") self.assertEqual(resp.status_code, 204) @@ -533,7 +535,7 @@ def test_delete_image_type_asset(self): # upload image response = self.client.post(self.url, {"name": "delete_image_test", "file": image_asset}) self.assertEqual(response.status_code, 200) - uploaded_image_url = json.loads(response.content.decode('utf-8'))['asset']['url'] + uploaded_image_url = json.loads(response.content.decode('utf-8'))['asset']['id'] # upload image thumbnail response = self.client.post(self.url, {"name": "delete_image_thumb_test", "file": thumbnail_image_asset}) @@ -566,7 +568,7 @@ def test_delete_asset_with_invalid_asset(self): def test_delete_asset_with_invalid_thumbnail(self): """ Tests the sad path :( """ test_url = reverse_course_url( - 'assets_handler', self.course.id, kwargs={'asset_key_string': str(self.uploaded_url)}) + 'assets_handler', self.course.id, kwargs={'asset_key_string': self.uploaded_id}) self.content.thumbnail_location = StaticContent.get_location_from_path('/c4x/edX/toy/asset/invalid') contentstore().save(self.content) resp = self.client.delete(test_url, HTTP_ACCEPT="application/json")