'Tests the caching mechanism and override to make sure we only publish
recently updated courses.'

@mock.patch(u'openedx.core.djangoapps.coursegraph.tasks.NodeSelector')
@mock.patch(u'openedx.core.djangoapps.coursegraph.tasks.authenticate_and_create_graph')
@ddt.data((True, 2), (False, 0))
@ddt.unpack
def test_dump_to_neo4j_cache(self, override_cache, expected_number_courses, mock_graph_constructor, mock_selector_class):

    mock_graph = MockGraph()
    mock_graph_constructor.return_value = mock_graph
    mock_selector_class.return_value = MockNodeSelector(mock_graph)
    mock_credentials = mock.Mock()
    self.mss.dump_courses_to_neo4j(mock_credentials, override_cache=override_cache)
    (submitted, __) = self.mss.dump_courses_to_neo4j(mock_credentials, override_cache=override_cache)
    self.assertEqual(len(submitted), expected_number_courses)
