refactor: xmodule/html_module.py -> xmodule/html_block.py
This commit is contained in:
@@ -20,7 +20,7 @@ from django.http import HttpResponseBadRequest
|
||||
from django.utils.translation import gettext as _
|
||||
|
||||
from openedx.core.lib.xblock_utils import get_course_update_items
|
||||
from xmodule.html_module import CourseInfoBlock # lint-amnesty, pylint: disable=wrong-import-order
|
||||
from xmodule.html_block import CourseInfoBlock # lint-amnesty, pylint: disable=wrong-import-order
|
||||
from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=wrong-import-order
|
||||
from xmodule.modulestore.exceptions import ItemNotFoundError # lint-amnesty, pylint: disable=wrong-import-order
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ class BackfillCourseOutlinesTest(SharedModuleStoreTestCase):
|
||||
ItemFactory.create(
|
||||
parent=unit,
|
||||
category="html",
|
||||
display_name="An HTML Module"
|
||||
display_name="An HTML Block"
|
||||
)
|
||||
|
||||
def test_end_to_end(self):
|
||||
|
||||
@@ -283,14 +283,14 @@ class ImportRequiredTestCases(ContentStoreTestCase):
|
||||
|
||||
# first check a static asset link
|
||||
course_key = self.store.make_course_key('edX', 'toy', 'run')
|
||||
html_module_location = course_key.make_usage_key('html', 'nonportable')
|
||||
html_module = self.store.get_item(html_module_location)
|
||||
self.assertIn('/static/foo.jpg', html_module.data)
|
||||
html_block_location = course_key.make_usage_key('html', 'nonportable')
|
||||
html_block = self.store.get_item(html_block_location)
|
||||
self.assertIn('/static/foo.jpg', html_block.data)
|
||||
|
||||
# then check a intra courseware link
|
||||
html_module_location = course_key.make_usage_key('html', 'nonportable_link')
|
||||
html_module = self.store.get_item(html_module_location)
|
||||
self.assertIn('/jump_to_id/nonportable_link', html_module.data)
|
||||
html_block_location = course_key.make_usage_key('html', 'nonportable_link')
|
||||
html_block = self.store.get_item(html_block_location)
|
||||
self.assertIn('/jump_to_id/nonportable_link', html_block.data)
|
||||
|
||||
def verify_content_existence(self, store, root_dir, course_id, dirname, category_name, filename_suffix=''): # lint-amnesty, pylint: disable=missing-function-docstring
|
||||
filesystem = OSFS(root_dir / 'test_export')
|
||||
@@ -525,12 +525,12 @@ class ImportRequiredTestCases(ContentStoreTestCase):
|
||||
import_course_from_xml(self.store, self.user.id, root_dir, create_if_not_present=True)
|
||||
|
||||
# get the sample HTML with styling information
|
||||
html_module = self.store.get_item(course_id.make_usage_key('html', 'with_styling'))
|
||||
self.assertIn('<p style="font:italic bold 72px/30px Georgia, serif; color: red; ">', html_module.data)
|
||||
html_block = self.store.get_item(course_id.make_usage_key('html', 'with_styling'))
|
||||
self.assertIn('<p style="font:italic bold 72px/30px Georgia, serif; color: red; ">', html_block.data)
|
||||
|
||||
# get the sample HTML with just a simple <img> tag information
|
||||
html_module = self.store.get_item(course_id.make_usage_key('html', 'just_img'))
|
||||
self.assertIn('<img src="/static/foo_bar.jpg" />', html_module.data)
|
||||
html_block = self.store.get_item(course_id.make_usage_key('html', 'just_img'))
|
||||
self.assertIn('<img src="/static/foo_bar.jpg" />', html_block.data)
|
||||
|
||||
def test_export_course_without_content_store(self):
|
||||
# Create toy course
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
from xmodule import templates
|
||||
from xmodule.capa_block import ProblemBlock
|
||||
from xmodule.course_block import CourseBlock
|
||||
from xmodule.html_module import HtmlBlock
|
||||
from xmodule.html_block import HtmlBlock
|
||||
from xmodule.modulestore import ModuleStoreEnum
|
||||
from xmodule.modulestore.exceptions import DuplicateCourseError
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
|
||||
|
||||
@@ -56,7 +56,7 @@ class TestOrphanBase(CourseTestCase):
|
||||
orphan_vertical.children.append(multi_parent_html.location)
|
||||
self.store.update_item(orphan_vertical, self.user.id)
|
||||
|
||||
# create an orphaned html module
|
||||
# create an orphaned html block
|
||||
orphan_html = self.store.create_item(self.user.id, course.id, 'html', "OrphanHtml")
|
||||
self.store.publish(orphan_html.location, self.user.id)
|
||||
|
||||
|
||||
@@ -192,15 +192,15 @@ class CourseTestCase(ProceduralCourseTestMixin, ModuleStoreTestCase):
|
||||
content_store.set_attr(self.LOCKED_ASSET_KEY, 'locked', True)
|
||||
|
||||
# create a non-portable link - should be rewritten in new courses
|
||||
html_module = self.store.get_item(course_id.make_usage_key('html', 'nonportable'))
|
||||
new_data = html_module.data = html_module.data.replace(
|
||||
html_block = self.store.get_item(course_id.make_usage_key('html', 'nonportable'))
|
||||
new_data = html_block.data = html_block.data.replace(
|
||||
'/static/',
|
||||
f'/c4x/{course_id.org}/{course_id.course}/asset/'
|
||||
)
|
||||
self.store.update_item(html_module, self.user.id)
|
||||
self.store.update_item(html_block, self.user.id)
|
||||
|
||||
html_module = self.store.get_item(html_module.location)
|
||||
self.assertEqual(new_data, html_module.data)
|
||||
html_block = self.store.get_item(html_block.location)
|
||||
self.assertEqual(new_data, html_block.data)
|
||||
|
||||
return course_id
|
||||
|
||||
@@ -272,8 +272,8 @@ class CourseTestCase(ProceduralCourseTestMixin, ModuleStoreTestCase):
|
||||
self.assertAssetsEqual(self.LOCKED_ASSET_KEY, self.LOCKED_ASSET_KEY.course_key, course_id)
|
||||
|
||||
# verify non-portable links are rewritten
|
||||
html_module = self.store.get_item(course_id.make_usage_key('html', 'nonportable'))
|
||||
self.assertIn('/static/foo.jpg', html_module.data)
|
||||
html_block = self.store.get_item(course_id.make_usage_key('html', 'nonportable'))
|
||||
self.assertIn('/static/foo.jpg', html_block.data)
|
||||
|
||||
return course
|
||||
|
||||
|
||||
@@ -728,7 +728,7 @@ class TestCourseReIndex(CourseTestCase):
|
||||
self.assertContains(response, self.SUCCESSFUL_RESPONSE)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
@mock.patch('xmodule.html_module.HtmlBlock.index_dictionary')
|
||||
@mock.patch('xmodule.html_block.HtmlBlock.index_dictionary')
|
||||
def test_reindex_course_search_index_error(self, mock_index_dictionary):
|
||||
"""
|
||||
Test json response with mocked error data for html
|
||||
@@ -791,7 +791,7 @@ class TestCourseReIndex(CourseTestCase):
|
||||
with self.assertRaises(SearchIndexingError):
|
||||
reindex_course_and_check_access(self.course.id, self.user)
|
||||
|
||||
@mock.patch('xmodule.html_module.HtmlBlock.index_dictionary')
|
||||
@mock.patch('xmodule.html_block.HtmlBlock.index_dictionary')
|
||||
def test_reindex_html_error_json_responses(self, mock_index_dictionary):
|
||||
"""
|
||||
Test json response with mocked error data for html
|
||||
@@ -901,7 +901,7 @@ class TestCourseReIndex(CourseTestCase):
|
||||
with self.assertRaises(SearchIndexingError):
|
||||
CoursewareSearchIndexer.do_course_reindex(modulestore(), self.course.id)
|
||||
|
||||
@mock.patch('xmodule.html_module.HtmlBlock.index_dictionary')
|
||||
@mock.patch('xmodule.html_block.HtmlBlock.index_dictionary')
|
||||
def test_indexing_html_error_responses(self, mock_index_dictionary):
|
||||
"""
|
||||
Test do_course_reindex response with mocked error data for html
|
||||
|
||||
Reference in New Issue
Block a user