diff --git a/cms/djangoapps/contentstore/tests/tests.py b/cms/djangoapps/contentstore/tests/tests.py index 8c520eb39c..b503a1819d 100644 --- a/cms/djangoapps/contentstore/tests/tests.py +++ b/cms/djangoapps/contentstore/tests/tests.py @@ -418,6 +418,17 @@ class ContentStoreTest(TestCase): items = ms.get_items(Location(['i4x','edX', 'full', 'vertical', None])) self.assertEqual(len(items), 0) + def verify_content_existence(self, modulestore, root_dir, location, dirname, category_name, filename_suffix=''): + fs = OSFS(root_dir / 'test_export') + self.assertTrue(fs.exists(dirname)) + + query_loc = Location('i4x', location.org, location.course, category_name, None) + items = modulestore.get_items(query_loc) + + for item in items: + fs = OSFS(root_dir / ('test_export/' + dirname)) + self.assertTrue(fs.exists(item.location.name + filename_suffix)) + def test_export_course(self): ms = modulestore('direct') cs = contentstore() @@ -433,26 +444,14 @@ class ContentStoreTest(TestCase): export_to_xml(ms, cs, location, root_dir, 'test_export') # check for static tabs - fs = OSFS(root_dir / 'test_export') - self.assertTrue(fs.exists('tabs')) - - static_tabs_query_loc = Location('i4x', location.org, location.course, 'static_tab', None) - static_tabs = ms.get_items(static_tabs_query_loc) - - for static_tab in static_tabs: - fs = OSFS(root_dir / 'test_export/tabs') - self.assertTrue(fs.exists(static_tab.location.name + '.html')) + self.verify_content_existence(ms, root_dir, location, 'tabs', 'static_tab', '.html') # check for custom_tags - fs = OSFS(root_dir / 'test_export') - self.assertTrue(fs.exists('custom_tags')) + self.verify_content_existence(ms, root_dir, location, 'info', 'course_info', '.html') - custom_tags_query_loc = Location('i4x', location.org, location.course, 'custom_tag_template', None) - custom_tags = ms.get_items(custom_tags_query_loc) - - for custom_tag in custom_tags: - fs = OSFS(root_dir / 'test_export/custom_tags') - self.assertTrue(fs.exists(custom_tag.location.name)) + # check for custom_tags + self.verify_content_existence(ms, root_dir, location, 'custom_tags', 'custom_tag_template') + # remove old course delete_course(ms, cs, location) @@ -469,6 +468,7 @@ class ContentStoreTest(TestCase): shutil.rmtree(root_dir) + def test_course_handouts_rewrites(self): ms = modulestore('direct') cs = contentstore() diff --git a/common/test/data/full/tabs/resources.html b/common/test/data/full/tabs/resources.html index 62e77a8416..bf78c92fb1 100644 --- a/common/test/data/full/tabs/resources.html +++ b/common/test/data/full/tabs/resources.html @@ -1 +1 @@ -This is another sample tab \ No newline at end of file +
This is another sample tab
\ No newline at end of file