Commit e24eb3e4 by Chris Dodge

added explicit unit test to verify the link rewriting

parent 80e0b993
......@@ -3,7 +3,7 @@
<chapter url_name="Overview">
<videosequence url_name="Toy_Videos">
<html url_name="secret:toylab"/>
<html url_name="secret:toyjumpto"/>
<html url_name="toyjumpto"/>
<video url_name="Video_Resources" youtube_id_1_0="1bK-WdDi6Qw" display_name="Video Resources"/>
</videosequence>
<video url_name="Welcome" youtube_id_1_0="p2Q6BrNhdh8" display_name="Welcome"/>
......
......@@ -17,6 +17,8 @@ from courseware.tests.tests import LoginEnrollmentTestCase
from courseware.model_data import ModelDataCache
from modulestore_config import TEST_DATA_XML_MODULESTORE
from courseware.courses import get_course_with_access
from .factories import UserFactory
......@@ -50,6 +52,30 @@ class ModuleRenderTestCase(LoginEnrollmentTestCase):
self.assertIsNone(render.get_module('dummyuser', None,
'invalid location', None, None))
def test_module_render_with_jump_to_id(self):
"""
This test validates that the /jump_to_id/<id> shorthand for intracourse linking works assertIn
expected. Note there's a HTML element in the 'toy' course with the url_name 'toyjumpto' which
defines this linkage
"""
mock_request = MagicMock()
mock_request.user = self.mock_user
course = get_course_with_access(self.mock_user, self.course_id, 'load')
model_data_cache = ModelDataCache.cache_for_descriptor_descendents(
self.course_id, self.mock_user, course, depth=2)
module = render.get_module(self.mock_user, mock_request, ['i4x', 'edX', 'toy', 'html', 'toyjumpto'],
model_data_cache, self.course_id)
# get the rendered HTML output which should have the rewritten link
html = module.get_html()
# See if the url got rewritten to the target link
# note if the URL mapping changes then this assertion will break
self.assertIn('/courses/'+self.course_id+'/jump_to_id/vertical_test', html)
def test_modx_dispatch(self):
self.assertRaises(Http404, render.modx_dispatch, 'dummy', 'dummy',
'invalid Location', 'dummy')
......
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