'Imports the test toy course and populates it with additional test data'

def import_and_populate_course(self):

    content_store = contentstore()
    import_course_from_xml(self.store, self.user.id, TEST_DATA_DIR, ['toy'], static_content_store=content_store)
    course_id = CourseKey.from_string('/'.join(['edX', 'toy', '2012_Fall']))
    vertical = self.store.get_item(course_id.make_usage_key('vertical', self.TEST_VERTICAL), depth=1)
    vertical.location = vertical.location.replace(name='no_references')
    self.store.update_item(vertical, self.user.id, allow_not_found=True)
    orphan_vertical = self.store.get_item(vertical.location)
    self.assertEqual(orphan_vertical.location.name, 'no_references')
    self.assertEqual(len(orphan_vertical.children), len(vertical.children))
    orphan_draft_vertical = self.store.create_item(self.user.id, course_id, 'vertical', self.ORPHAN_DRAFT_VERTICAL)
    orphan_draft_html = self.store.create_item(self.user.id, course_id, 'html', self.ORPHAN_DRAFT_HTML)
    orphan_draft_vertical.children.append(orphan_draft_html.location)
    self.store.update_item(orphan_draft_vertical, self.user.id)
    vertical = self.store.get_item(course_id.make_usage_key('vertical', self.TEST_VERTICAL), depth=1)
    draft_vertical = self.store.convert_to_draft(vertical.location, self.user.id)
    self.assertTrue(self.store.has_published_version(draft_vertical))
    private_vertical = self.store.create_item(self.user.id, course_id, 'vertical', self.PRIVATE_VERTICAL)
    self.assertFalse(self.store.has_published_version(private_vertical))
    public_vertical = self.store.create_item(self.user.id, course_id, 'vertical', self.PUBLISHED_VERTICAL)
    public_vertical = self.store.publish(public_vertical.location, self.user.id)
    self.assertTrue(self.store.has_published_version(public_vertical))
    sequential = self.store.get_item(course_id.make_usage_key('sequential', self.SEQUENTIAL))
    sequential.children.append(private_vertical.location)
    sequential.children.append(public_vertical.location)
    self.store.update_item(sequential, self.user.id)
    draft_html = self.store.create_item(self.user.id, course_id, 'html', self.DRAFT_HTML)
    draft_video = self.store.create_item(self.user.id, course_id, 'video', self.DRAFT_VIDEO)
    public_vertical.children.append(draft_html.location)
    public_vertical.children.append(draft_video.location)
    self.store.update_item(public_vertical, self.user.id)
    self.store.publish(public_vertical.location, self.user.id)
    self.store.convert_to_draft(draft_html.location, self.user.id)
    self.store.convert_to_draft(draft_video.location, self.user.id)
    content_store.set_attr(self.LOCKED_ASSET_KEY, 'locked', True)
    html_module = self.store.get_item(course_id.make_usage_key('html', 'nonportable'))
    new_data = html_module.data = html_module.data.replace('/static/', '/c4x/{0}/{1}/asset/'.format(course_id.org, course_id.course))
    self.store.update_item(html_module, self.user.id)
    html_module = self.store.get_item(html_module.location)
    self.assertEqual(new_data, html_module.data)
    return course_id
