'Test that course info updates are imported and exported with all content fields (\'data\', \'items\')'

def test_course_info_updates_import_export(self):

    content_store = contentstore()
    data_dir = TEST_DATA_DIR
    courses = import_course_from_xml(self.store, self.user.id, data_dir, ['course_info_updates'], static_content_store=content_store, verbose=True, create_if_not_present=True)
    course = courses[0]
    self.assertIsNotNone(course)
    course_updates = self.store.get_item(course.id.make_usage_key('course_info', 'updates'))
    self.assertIsNotNone(course_updates)
    filesystem = OSFS((data_dir + '/course_info_updates/info'))
    self.assertTrue(filesystem.exists('updates.html'))
    self.assertTrue(filesystem.exists('updates.items.json'))
    with filesystem.open('updates.html', 'r') as course_policy:
        on_disk = course_policy.read()
        self.assertEqual(course_updates.data, on_disk)
    with filesystem.open('updates.items.json', 'r') as course_policy:
        on_disk = loads(course_policy.read())
        self.assertEqual(course_updates.items, on_disk)
    root_dir = path(mkdtemp_clean())
    print 'Exporting    to    tempdir    =    {0}'.format(root_dir)
    export_course_to_xml(self.store, content_store, course.id, root_dir, 'test_export')
    filesystem = OSFS((root_dir / 'test_export/info'))
    self.assertTrue(filesystem.exists('updates.html'))
    self.assertTrue(filesystem.exists('updates.items.json'))
    with filesystem.open('updates.html', 'r') as grading_policy:
        on_disk = grading_policy.read()
        self.assertEqual(on_disk, course_updates.data)
    with filesystem.open('updates.items.json', 'r') as grading_policy:
        on_disk = loads(grading_policy.read())
        self.assertEqual(on_disk, course_updates.items)
