fix tests
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
from static_replace import replace_static_urls
|
||||
from xmodule.modulestore.exceptions import ItemNotFoundError
|
||||
from xmodule.modulestore import Location
|
||||
|
||||
|
||||
def get_module_info(store, location, rewrite_static_links=False):
|
||||
@@ -16,13 +15,7 @@ def get_module_info(store, location, rewrite_static_links=False):
|
||||
data = replace_static_urls(
|
||||
module.data,
|
||||
None,
|
||||
course_namespace=Location([
|
||||
module.location.tag,
|
||||
module.location.org,
|
||||
module.location.course,
|
||||
None,
|
||||
None
|
||||
])
|
||||
course_id=module.location.org + '/' + module.location.course + '/REPLACE_WITH_RUN_WHEN_IMPLEMENTED'
|
||||
)
|
||||
|
||||
return {
|
||||
|
||||
@@ -10,7 +10,6 @@ from xmodule.modulestore.xml import XMLModuleStore
|
||||
|
||||
DATA_DIRECTORY = 'data_dir'
|
||||
COURSE_ID = 'org/course/run'
|
||||
NAMESPACE = Location('org', 'course', 'run', None, None)
|
||||
STATIC_SOURCE = '"/static/file.png"'
|
||||
|
||||
|
||||
@@ -52,18 +51,18 @@ def test_storage_url_not_exists(mock_storage):
|
||||
def test_mongo_filestore(mock_modulestore, mock_static_content):
|
||||
|
||||
mock_modulestore.return_value = Mock(MongoModuleStore)
|
||||
mock_static_content.convert_legacy_static_url.return_value = "c4x://mock_url"
|
||||
mock_static_content.convert_legacy_static_url_with_course_id.return_value = "c4x://mock_url"
|
||||
|
||||
# No namespace => no change to path
|
||||
assert_equals('"/static/data_dir/file.png"', replace_static_urls(STATIC_SOURCE, DATA_DIRECTORY))
|
||||
|
||||
# Namespace => content url
|
||||
assert_equals(
|
||||
'"' + mock_static_content.convert_legacy_static_url.return_value + '"',
|
||||
replace_static_urls(STATIC_SOURCE, DATA_DIRECTORY, NAMESPACE)
|
||||
'"' + mock_static_content.convert_legacy_static_url_with_course_id.return_value + '"',
|
||||
replace_static_urls(STATIC_SOURCE, DATA_DIRECTORY, course_id=COURSE_ID)
|
||||
)
|
||||
|
||||
mock_static_content.convert_legacy_static_url.assert_called_once_with('file.png', NAMESPACE)
|
||||
mock_static_content.convert_legacy_static_url_with_course_id.assert_called_once_with('file.png', COURSE_ID)
|
||||
|
||||
|
||||
@patch('static_replace.settings')
|
||||
|
||||
@@ -54,7 +54,7 @@ class TestVideo(BaseTestXmodule):
|
||||
|
||||
expected_context = {
|
||||
'data_dir': getattr(self, 'data_dir', None),
|
||||
'caption_asset_path': '/c4x/MITx/999/asset/subs_',
|
||||
'caption_asset_path': '/static/subs/',
|
||||
'show_captions': 'true',
|
||||
'display_name': 'A Name',
|
||||
'end': 3610.0,
|
||||
@@ -104,10 +104,17 @@ class TestVideoNonYouTube(TestVideo):
|
||||
|
||||
expected_context = {
|
||||
'data_dir': getattr(self, 'data_dir', None),
|
||||
<<<<<<< HEAD
|
||||
'caption_asset_path': '/c4x/MITx/999/asset/subs_',
|
||||
'show_captions': 'true',
|
||||
'display_name': 'A Name',
|
||||
'end': 3610.0,
|
||||
=======
|
||||
'caption_asset_path': '/static/subs/',
|
||||
'show_captions': self.item_module.show_captions,
|
||||
'display_name': self.item_module.display_name_with_default,
|
||||
'end': self.item_module.end_time,
|
||||
>>>>>>> fix tests
|
||||
'id': self.item_module.location.html_id(),
|
||||
'sources': sources,
|
||||
'start': 3603.0,
|
||||
|
||||
@@ -50,7 +50,7 @@ def remap_static_url(original_url, course):
|
||||
output_url = replace_static_urls(
|
||||
input_url,
|
||||
getattr(course, 'data_dir', None),
|
||||
coures_id=course.location.course_id,
|
||||
course_id=course.location.course_id,
|
||||
)
|
||||
# strip off the quotes again...
|
||||
return output_url[1:-1]
|
||||
|
||||
Reference in New Issue
Block a user