Commit 8db7b0ce by cahrens

Add test for external_url being passed to assets page.

parent 3553fa7c
......@@ -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"])
......
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