Commit fc57e7af by Chris Dodge

add testing for course info export. Plus DRY things out a bit

parent 0d20c192
......@@ -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'))
custom_tags_query_loc = Location('i4x', location.org, location.course, 'custom_tag_template', None)
custom_tags = ms.get_items(custom_tags_query_loc)
self.verify_content_existence(ms, root_dir, location, 'info', 'course_info', '.html')
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()
......
This is another sample tab
\ No newline at end of file
<p>This is another sample tab</p>
\ No newline at end of file
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