'Tests that the the dump_to_neo4j method handles the case where there\'s
an exception trying to write to the neo4j database.'

@mock.patch(u'openedx.core.djangoapps.coursegraph.tasks.NodeSelector')
@mock.patch(u'openedx.core.djangoapps.coursegraph.tasks.authenticate_and_create_graph')
def test_dump_to_neo4j_rollback(self, mock_graph_constructor, mock_selector_class):

    mock_graph = MockGraph(transaction_errors=True)
    mock_graph_constructor.return_value = mock_graph
    mock_selector_class.return_value = MockNodeSelector(mock_graph)
    mock_credentials = mock.Mock()
    (submitted, skipped) = self.mss.dump_courses_to_neo4j(mock_credentials)
    self.assertCourseDump(mock_graph, number_of_courses=0, number_commits=0, number_rollbacks=2)
    self.assertItemsEqual(submitted, self.course_strings)
