From 8db7b0ce215d52cb09a520c1b2d96368126f7e24 Mon Sep 17 00:00:00 2001 From: cahrens Date: Wed, 26 Feb 2014 09:26:50 -0500 Subject: [PATCH] Add test for external_url being passed to assets page. --- .../contentstore/views/tests/test_assets.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/cms/djangoapps/contentstore/views/tests/test_assets.py b/cms/djangoapps/contentstore/views/tests/test_assets.py index 6384269715..8d7b2a9008 100644 --- a/cms/djangoapps/contentstore/views/tests/test_assets.py +++ b/cms/djangoapps/contentstore/views/tests/test_assets.py @@ -18,6 +18,7 @@ from xmodule.contentstore.django import contentstore from xmodule.modulestore.django import modulestore from xmodule.modulestore.xml_importer import import_from_xml from xmodule.modulestore.django import loc_mapper +from django.test.utils import override_settings class AssetsTestCase(CourseTestCase): @@ -36,21 +37,15 @@ class AssetsTestCase(CourseTestCase): class BasicAssetsTestCase(AssetsTestCase): - location = Location(['i4x', 'foo', 'bar', 'asset', 'my_file_name.jpg']) - TEST_LMS_BASE = 'localhost:8000' - def test_basic(self): resp = self.client.get(self.url, HTTP_ACCEPT='text/html') self.assertEquals(resp.status_code, 200) def test_static_url_generation(self): - path = StaticContent.get_static_path_from_location(self.location) + location = Location(['i4x', 'foo', 'bar', 'asset', 'my_file_name.jpg']) + path = StaticContent.get_static_path_from_location(location) self.assertEquals(path, '/static/my_file_name.jpg') - def test_lms_url_generation(self): - url = self.TEST_LMS_BASE + StaticContent.get_url_path_from_location(self.location) - self.assertEquals(url, 'localhost:8000/i4x/foo/bar/asset/my_file_name.jpg') - def test_pdf_asset(self): module_store = modulestore('direct') _, course_items = import_from_xml( @@ -144,6 +139,7 @@ class AssetToJsonTestCase(AssetsTestCase): Unit test for transforming asset information into something we can send out to the client via JSON. """ + @override_settings(LMS_BASE="lms_base_url") def test_basic(self): upload_date = datetime(2013, 6, 1, 10, 30, tzinfo=UTC) @@ -155,6 +151,7 @@ class AssetToJsonTestCase(AssetsTestCase): self.assertEquals(output["display_name"], "my_file") self.assertEquals(output["date_added"], "Jun 01, 2013 at 10:30 UTC") self.assertEquals(output["url"], "/i4x/foo/bar/asset/my_file_name.jpg") + self.assertEquals(output["external_url"], "lms_base_url/i4x/foo/bar/asset/my_file_name.jpg") self.assertEquals(output["portable_url"], "/static/my_file_name.jpg") self.assertEquals(output["thumbnail"], "/i4x/foo/bar/asset/my_file_name_thumb.jpg") self.assertEquals(output["id"], output["url"])