Commit 4b9dc74c by Waqas Khalid

Add tests for rename import error

parent 80b5f382
......@@ -52,6 +52,7 @@ from course_action_state.models import CourseRerunState, CourseRerunUIStateManag
from course_action_state.managers import CourseActionStateItemNotFoundError
from xmodule.contentstore.content import StaticContent
from xmodule.modulestore.django import modulestore
TEST_DATA_CONTENTSTORE = copy.deepcopy(settings.CONTENTSTORE)
......@@ -387,6 +388,32 @@ class ImportRequiredTestCases(ContentStoreTestCase):
shutil.rmtree(root_dir)
def test_import_after_renaming_xml_data(self):
"""
Test that import works fine on split mongo after renaming the blocks url.
"""
split_store = modulestore()._get_modulestore_by_type(ModuleStoreEnum.Type.split) # pylint: disable=W0212
import_from_xml(
split_store, self.user.id, TEST_DATA_DIR,
['course_before_rename'],
create_course_if_not_present=True
)
course_after_rename = import_from_xml(
split_store, self.user.id, TEST_DATA_DIR,
['course_after_rename'],
create_course_if_not_present=True
)
all_items = split_store.get_items(course_after_rename[0].id, qualifiers={'category': 'chapter'})
renamed_chapter = [item for item in all_items if item.location.block_id == 'renamed_chapter'][0]
self.assertIsNotNone(renamed_chapter.published_on)
self.assertIsNotNone(renamed_chapter.parent)
self.assertTrue(renamed_chapter.location in course_after_rename[0].children)
original_chapter = [item for item in all_items
if item.location.block_id == 'b9870b9af59841a49e6e02765d0e3bbf'][0]
self.assertIsNone(original_chapter.published_on)
self.assertIsNone(original_chapter.parent)
self.assertFalse(original_chapter.location in course_after_rename[0].children)
def test_empty_data_roundtrip(self):
"""
Test that an empty `data` field is preserved through
......
<section class="about">
<h2>About This Course</h2>
<p>Include your long course description here. The long course description should contain 150-400 words.</p>
<p>This is paragraph 2 of the long course description. Add more paragraphs as needed. Make sure to enclose them in paragraph tags.</p>
</section>
<section class="prerequisites">
<h2>Requirements</h2>
<p>Add information about the skills and knowledge students need to take this course.</p>
</section>
<section class="course-staff">
<h2>Course Staff</h2>
<article class="teacher">
<div class="teacher-image">
<img src="/static/images/placeholder-faculty.png" align="left" style="margin:0 20 px 0" alt="Course Staff Image #1">
</div>
<h3>Staff Member #1</h3>
<p>Biography of instructor/staff member #1</p>
</article>
<article class="teacher">
<div class="teacher-image">
<img src="/static/images/placeholder-faculty.png" align="left" style="margin:0 20 px 0" alt="Course Staff Image #2">
</div>
<h3>Staff Member #2</h3>
<p>Biography of instructor/staff member #2</p>
</article>
</section>
<section class="faq">
<section class="responses">
<h2>Frequently Asked Questions</h2>
<article class="response">
<h3>Do I need to buy a textbook?</h3>
<p>No, a free online version of Chemistry: Principles, Patterns, and Applications, First Edition by Bruce Averill and Patricia Eldredge will be available, though you can purchase a printed version (published by FlatWorld Knowledge) if you’d like.</p>
</article>
<article class="response">
<h3>Question #2</h3>
<p>Your answer would be displayed here.</p>
</article>
</section>
</section>
<chapter display_name="Discussion">
<sequential url_name="761dd4188c3e49f390a8d2a47156f503"/>
</chapter>
<course url_name="course" org="malikx" course="cs101"/>
\ No newline at end of file
<course display_name="Import testing" start="&quot;2030-01-01T00:00:00+00:00&quot;">
<chapter url_name="renamed_chapter"/>
<wiki slug="malikx.cs101.2014"/>
</course>
<vertical display_name="Unit" parent_url="block-v1:malikx+cs101+2015+type@sequential+block@761dd4188c3e49f390a8d2a47156f503" index_in_children_list="0"/>
{
"GRADER": [
{
"drop_count": 2,
"min_count": 12,
"short_label": "HW",
"type": "Homework",
"weight": 0.15
},
{
"drop_count": 2,
"min_count": 12,
"type": "Lab",
"weight": 0.15
},
{
"drop_count": 0,
"min_count": 1,
"short_label": "Midterm",
"type": "Midterm Exam",
"weight": 0.3
},
{
"drop_count": 0,
"min_count": 1,
"short_label": "Final",
"type": "Final Exam",
"weight": 0.4
}
],
"GRADE_CUTOFFS": {
"Pass": 0.5
}
}
\ No newline at end of file
{
"course/course": {
"discussion_topics": {
"General": {
"id": "i4x-malikx-cs101-course-2014"
}
},
"display_name": "Import testing",
"start": "2030-01-01T00:00:00Z",
"tabs": [
{
"name": "Courseware",
"type": "courseware"
},
{
"name": "Course Info",
"type": "course_info"
},
{
"name": "Textbooks",
"type": "textbooks"
},
{
"name": "Discussion",
"type": "discussion"
},
{
"name": "Wiki",
"type": "wiki"
},
{
"name": "Progress",
"type": "progress"
}
]
}
}
\ No newline at end of file
<sequential display_name="Subsection">
<vertical url_name="f8ee1d2026e048b884d2ff6c4daa9def"/>
</sequential>
<section class="about">
<h2>About This Course</h2>
<p>Include your long course description here. The long course description should contain 150-400 words.</p>
<p>This is paragraph 2 of the long course description. Add more paragraphs as needed. Make sure to enclose them in paragraph tags.</p>
</section>
<section class="prerequisites">
<h2>Requirements</h2>
<p>Add information about the skills and knowledge students need to take this course.</p>
</section>
<section class="course-staff">
<h2>Course Staff</h2>
<article class="teacher">
<div class="teacher-image">
<img src="/static/images/placeholder-faculty.png" align="left" style="margin:0 20 px 0" alt="Course Staff Image #1">
</div>
<h3>Staff Member #1</h3>
<p>Biography of instructor/staff member #1</p>
</article>
<article class="teacher">
<div class="teacher-image">
<img src="/static/images/placeholder-faculty.png" align="left" style="margin:0 20 px 0" alt="Course Staff Image #2">
</div>
<h3>Staff Member #2</h3>
<p>Biography of instructor/staff member #2</p>
</article>
</section>
<section class="faq">
<section class="responses">
<h2>Frequently Asked Questions</h2>
<article class="response">
<h3>Do I need to buy a textbook?</h3>
<p>No, a free online version of Chemistry: Principles, Patterns, and Applications, First Edition by Bruce Averill and Patricia Eldredge will be available, though you can purchase a printed version (published by FlatWorld Knowledge) if you’d like.</p>
</article>
<article class="response">
<h3>Question #2</h3>
<p>Your answer would be displayed here.</p>
</article>
</section>
</section>
<chapter display_name="Discussion">
<sequential url_name="761dd4188c3e49f390a8d2a47156f503"/>
</chapter>
<course url_name="course" org="malikx" course="cs101"/>
\ No newline at end of file
<course display_name="Import testing" start="&quot;2030-01-01T00:00:00+00:00&quot;">
<chapter url_name="b9870b9af59841a49e6e02765d0e3bbf"/>
<wiki slug="malikx.cs101.2014"/>
</course>
<vertical display_name="Unit" parent_url="block-v1:malikx+cs101+2015+type@sequential+block@761dd4188c3e49f390a8d2a47156f503" index_in_children_list="0"/>
{
"GRADER": [
{
"drop_count": 2,
"min_count": 12,
"short_label": "HW",
"type": "Homework",
"weight": 0.15
},
{
"drop_count": 2,
"min_count": 12,
"type": "Lab",
"weight": 0.15
},
{
"drop_count": 0,
"min_count": 1,
"short_label": "Midterm",
"type": "Midterm Exam",
"weight": 0.3
},
{
"drop_count": 0,
"min_count": 1,
"short_label": "Final",
"type": "Final Exam",
"weight": 0.4
}
],
"GRADE_CUTOFFS": {
"Pass": 0.5
}
}
\ No newline at end of file
{
"course/course": {
"discussion_topics": {
"General": {
"id": "i4x-malikx-cs101-course-2014"
}
},
"display_name": "Import testing",
"start": "2030-01-01T00:00:00Z",
"tabs": [
{
"name": "Courseware",
"type": "courseware"
},
{
"name": "Course Info",
"type": "course_info"
},
{
"name": "Textbooks",
"type": "textbooks"
},
{
"name": "Discussion",
"type": "discussion"
},
{
"name": "Wiki",
"type": "wiki"
},
{
"name": "Progress",
"type": "progress"
}
]
}
}
\ No newline at end of file
<sequential display_name="Subsection">
<vertical url_name="f8ee1d2026e048b884d2ff6c4daa9def"/>
</sequential>
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