'Tests that we only dump those courses that have been published after
the last time the command was been run.'

@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_published(self, 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()
    (submitted, skipped) = self.mss.dump_courses_to_neo4j(mock_credentials)
    self.assertEqual(len(submitted), len(self.course_strings))
    listen_for_course_publish(None, self.course.id)
    (submitted, __) = self.mss.dump_courses_to_neo4j(mock_credentials)
    self.assertEqual(len(submitted), 1)
    self.assertEqual(submitted[0], six.text_type(self.course.id))
