Convert AboutModule, CourseInfoModule, HtmlModule and StaticTabModule to XBlocks.

This commit is contained in:
Usman Khalid
2019-07-06 03:18:38 +05:00
parent 8526a989c3
commit 8dfc8e5fda
21 changed files with 139 additions and 153 deletions

View File

@@ -22,7 +22,7 @@ from django.utils.translation import ugettext as _
from cms.djangoapps.contentstore.push_notification import enqueue_push_course_update
from openedx.core.lib.xblock_utils import get_course_update_items
from xmodule.html_module import CourseInfoModule
from xmodule.html_module import CourseInfoBlock
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.exceptions import ItemNotFoundError
@@ -76,7 +76,7 @@ def update_course_updates(location, update, passed_id=None, user=None):
"id": len(course_update_items) + 1,
"date": update["date"],
"content": update["content"],
"status": CourseInfoModule.STATUS_VISIBLE
"status": CourseInfoBlock.STATUS_VISIBLE
}
course_update_items.append(course_update_dict)
enqueue_push_course_update(update, location.course_key)
@@ -106,14 +106,14 @@ def _get_visible_update(course_update_items):
"""
if isinstance(course_update_items, dict):
# single course update item
if course_update_items.get("status") != CourseInfoModule.STATUS_DELETED:
if course_update_items.get("status") != CourseInfoBlock.STATUS_DELETED:
return _make_update_dict(course_update_items)
else:
# requested course update item has been deleted (soft delete)
return {"error": _("Course update not found."), "status": 404}
return ([_make_update_dict(update) for update in course_update_items
if update.get("status") != CourseInfoModule.STATUS_DELETED])
if update.get("status") != CourseInfoBlock.STATUS_DELETED])
# pylint: disable=unused-argument
@@ -138,7 +138,7 @@ def delete_course_update(location, update, passed_id, user):
if 0 < passed_index <= len(course_update_items):
course_update_item = course_update_items[passed_index - 1]
# soft delete course update item
course_update_item["status"] = CourseInfoModule.STATUS_DELETED
course_update_item["status"] = CourseInfoBlock.STATUS_DELETED
course_update_items[passed_index - 1] = course_update_item
# update db record

View File

@@ -116,6 +116,6 @@ class TestDeleteOrphan(TestOrphanBase):
# there should be one in published
self.assertOrphanCount(course.id, 0)
self.assertOrphanCount(published_branch, 1)
self.assertIn(orphan, self.store.get_items(published_branch))
self.assertIn(orphan.location, [x.location for x in self.store.get_items(published_branch)])
return course, orphan

View File

@@ -5,7 +5,7 @@ from __future__ import absolute_import
from xmodule import templates
from xmodule.capa_module import ProblemBlock
from xmodule.course_module import CourseDescriptor
from xmodule.html_module import HtmlDescriptor
from xmodule.html_module import HtmlBlock
from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.exceptions import DuplicateCourseError
from xmodule.modulestore.tests.django_utils import TEST_DATA_SPLIT_MODULESTORE, ModuleStoreTestCase
@@ -44,10 +44,10 @@ class TemplateTests(ModuleStoreTestCase):
def test_get_some_templates(self):
self.assertEqual(len(SequenceDescriptor.templates()), 0)
self.assertGreater(len(HtmlDescriptor.templates()), 0)
self.assertGreater(len(HtmlBlock.templates()), 0)
self.assertIsNone(SequenceDescriptor.get_template('doesntexist.yaml'))
self.assertIsNone(HtmlDescriptor.get_template('doesntexist.yaml'))
self.assertIsNotNone(HtmlDescriptor.get_template('announcement.yaml'))
self.assertIsNone(HtmlBlock.get_template('doesntexist.yaml'))
self.assertIsNotNone(HtmlBlock.get_template('announcement.yaml'))
def test_factories(self):
test_course = CourseFactory.create(

View File

@@ -680,7 +680,7 @@ class TestCourseReIndex(CourseTestCase):
self.assertIn(self.SUCCESSFUL_RESPONSE, response.content)
self.assertEqual(response.status_code, 200)
@mock.patch('xmodule.html_module.HtmlDescriptor.index_dictionary')
@mock.patch('xmodule.html_module.HtmlBlock.index_dictionary')
def test_reindex_course_search_index_error(self, mock_index_dictionary):
"""
Test json response with mocked error data for html
@@ -743,7 +743,7 @@ class TestCourseReIndex(CourseTestCase):
with self.assertRaises(SearchIndexingError):
reindex_course_and_check_access(self.course.id, self.user)
@mock.patch('xmodule.html_module.HtmlDescriptor.index_dictionary')
@mock.patch('xmodule.html_module.HtmlBlock.index_dictionary')
def test_reindex_html_error_json_responses(self, mock_index_dictionary):
"""
Test json response with mocked error data for html
@@ -853,7 +853,7 @@ class TestCourseReIndex(CourseTestCase):
with self.assertRaises(SearchIndexingError):
CoursewareSearchIndexer.do_course_reindex(modulestore(), self.course.id)
@mock.patch('xmodule.html_module.HtmlDescriptor.index_dictionary')
@mock.patch('xmodule.html_module.HtmlBlock.index_dictionary')
def test_indexing_html_error_responses(self, mock_index_dictionary):
"""
Test do_course_reindex response with mocked error data for html