Commit a6035698 by Calen Pennington

Correctly compute course image location when using mongo modulestore

[LMS-2073]
[STUD-1197]
parent 923c2ff4
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
import collections import collections
import copy import copy
import mock import mock
from unittest import expectedFailure
from django.test import TestCase from django.test import TestCase
from django.test.utils import override_settings from django.test.utils import override_settings
...@@ -168,7 +167,6 @@ class CourseImageTestCase(TestCase): ...@@ -168,7 +167,6 @@ class CourseImageTestCase(TestCase):
url = utils.course_image_url(course) url = utils.course_image_url(course)
self.assertEquals(url, '/c4x/edX/999/asset/{0}'.format(course.course_image)) self.assertEquals(url, '/c4x/edX/999/asset/{0}'.format(course.course_image))
@expectedFailure
def test_non_ascii_image_name(self): def test_non_ascii_image_name(self):
# Verify that non-ascii image names are cleaned # Verify that non-ascii image names are cleaned
course = CourseFactory.create(course_image=u'before_\N{SNOWMAN}_after.jpg') course = CourseFactory.create(course_image=u'before_\N{SNOWMAN}_after.jpg')
......
...@@ -191,7 +191,7 @@ def get_lms_link_for_about_page(location): ...@@ -191,7 +191,7 @@ def get_lms_link_for_about_page(location):
def course_image_url(course): def course_image_url(course):
"""Returns the image url for the course.""" """Returns the image url for the course."""
loc = course.location._replace(tag='c4x', category='asset', name=course.course_image) loc = StaticContent.compute_location(course.location.org, course.location.course, course.course_image)
path = StaticContent.get_url_path_from_location(loc) path = StaticContent.get_url_path_from_location(loc)
return path return path
......
...@@ -106,7 +106,7 @@ def course_image_url(course): ...@@ -106,7 +106,7 @@ def course_image_url(course):
if course.static_asset_path or modulestore().get_modulestore_type(course.location.course_id) == XML_MODULESTORE_TYPE: if course.static_asset_path or modulestore().get_modulestore_type(course.location.course_id) == XML_MODULESTORE_TYPE:
return '/static/' + (course.static_asset_path or getattr(course, 'data_dir', '')) + "/images/course_image.jpg" return '/static/' + (course.static_asset_path or getattr(course, 'data_dir', '')) + "/images/course_image.jpg"
else: else:
loc = course.location.replace(tag='c4x', category='asset', name=course.course_image) loc = StaticContent.compute_location(course.location.org, course.location.course, course.course_image)
_path = StaticContent.get_url_path_from_location(loc) _path = StaticContent.get_url_path_from_location(loc)
return _path return _path
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
Tests for course access Tests for course access
""" """
import mock import mock
from unittest import expectedFailure
from django.http import Http404 from django.http import Http404
from django.test.utils import override_settings from django.test.utils import override_settings
...@@ -96,7 +95,6 @@ class MongoCourseImageTestCase(ModuleStoreTestCase): ...@@ -96,7 +95,6 @@ class MongoCourseImageTestCase(ModuleStoreTestCase):
course = CourseFactory.create(org='edX', course='999') course = CourseFactory.create(org='edX', course='999')
self.assertEquals(course_image_url(course), '/c4x/edX/999/asset/{0}'.format(course.course_image)) self.assertEquals(course_image_url(course), '/c4x/edX/999/asset/{0}'.format(course.course_image))
@expectedFailure
def test_non_ascii_image_name(self): def test_non_ascii_image_name(self):
# Verify that non-ascii image names are cleaned # Verify that non-ascii image names are cleaned
course = CourseFactory.create(course_image=u'before_\N{SNOWMAN}_after.jpg') course = CourseFactory.create(course_image=u'before_\N{SNOWMAN}_after.jpg')
......
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