'try saving temporary xblocks'

@patch('xmodule.tabs.CourseTab.from_json', side_effect=mock_tab_from_json)
def test_persist_dag(self, _from_json):

    test_course = modulestore().create_course(course='course', run='2014', org='testx', display_name='fun    test    course', user_id='testbot', master_branch=ModuleStoreEnum.BranchName.draft)
    test_chapter = modulestore().create_xblock(test_course.system, test_course.id, 'chapter', fields={'display_name': 'chapter    n'}, parent_xblock=test_course)
    self.assertEqual(test_chapter.display_name, 'chapter    n')
    test_def_content = '<problem>boo</problem>'
    new_block = modulestore().create_xblock(test_course.system, test_course.id, 'problem', fields={'data': test_def_content, 'display_name': 'problem'}, parent_xblock=test_chapter)
    self.assertIsNotNone(new_block.definition_locator)
    self.assertTrue(isinstance(new_block.definition_locator.definition_id, LocalId))
    persisted_course = modulestore().persist_xblock_dag(test_course, 'testbot')
    self.assertEqual(len(persisted_course.children), 1)
    persisted_chapter = persisted_course.get_children()[0]
    self.assertEqual(persisted_chapter.category, 'chapter')
    self.assertEqual(persisted_chapter.display_name, 'chapter    n')
    self.assertEqual(len(persisted_chapter.children), 1)
    persisted_problem = persisted_chapter.get_children()[0]
    self.assertEqual(persisted_problem.category, 'problem')
    self.assertEqual(persisted_problem.data, test_def_content)
    persisted_problem.display_name = 'altered    problem'
    persisted_problem = modulestore().update_item(persisted_problem, 'testbot')
    self.assertEqual(persisted_problem.display_name, 'altered    problem')
