Ejemplo n.º 1
0
    def test_dump_to_neo4j_published(self, mock_graph_constructor,
                                     mock_selector_class):
        """
        Tests that we only dump those courses that have been published after
        the last time the command was been run.
        """
        mock_graph = MockGraph()
        mock_graph_constructor.return_value = mock_graph
        mock_selector_class.return_value = MockNodeSelector(mock_graph)
        # mocking is thorwing error in kombu serialzier and its not require here any more.
        credentials = {}

        # run once to warm the cache
        submitted, skipped = self.mss.dump_courses_to_neo4j(credentials)
        self.assertEqual(len(submitted), len(self.course_strings))

        # simulate one of the courses being published
        with block_structure_config.waffle().override(
                block_structure_config.STORAGE_BACKING_FOR_CACHE):
            update_block_structure_on_course_publish(None, self.course.id)

        # make sure only the published course was dumped
        submitted, __ = self.mss.dump_courses_to_neo4j(credentials)
        self.assertEqual(len(submitted), 1)
        self.assertEqual(submitted[0], six.text_type(self.course.id))
Ejemplo n.º 2
0
    def test_dump_to_neo4j_published(self, mock_graph_constructor,
                                     mock_matcher_class):
        """
        Tests that we only dump those courses that have been published after
        the last time the command was been run.
        """
        mock_graph = MockGraph()
        mock_graph_constructor.return_value = mock_graph
        mock_matcher_class.return_value = MockNodeMatcher(mock_graph)
        # mocking is thorwing error in kombu serialzier and its not require here any more.
        credentials = {}

        # run once to warm the cache
        submitted, skipped = self.mss.dump_courses_to_neo4j(credentials)  # lint-amnesty, pylint: disable=unused-variable
        assert len(submitted) == len(self.course_strings)

        # simulate one of the courses being published
        with override_waffle_switch(
                block_structure_config.STORAGE_BACKING_FOR_CACHE, True):
            update_block_structure_on_course_publish(None, self.course.id)

        # make sure only the published course was dumped
        submitted, __ = self.mss.dump_courses_to_neo4j(credentials)
        assert len(submitted) == 1
        assert submitted[0] == str(self.course.id)
Ejemplo n.º 3
0
    def test_dump_to_neo4j_published(self, mock_graph_constructor, mock_selector_class):
        """
        Tests that we only dump those courses that have been published after
        the last time the command was been run.
        """
        mock_graph = MockGraph()
        mock_graph_constructor.return_value = mock_graph
        mock_selector_class.return_value = MockNodeSelector(mock_graph)
        mock_credentials = mock.Mock()

        # run once to warm the cache
        submitted, skipped = self.mss.dump_courses_to_neo4j(mock_credentials)
        self.assertEqual(len(submitted), len(self.course_strings))

        # simulate one of the courses being published
        with block_structure_config.waffle().override(block_structure_config.STORAGE_BACKING_FOR_CACHE):
            update_block_structure_on_course_publish(None, self.course.id)

        # make sure only the published course was dumped
        submitted, __ = self.mss.dump_courses_to_neo4j(mock_credentials)
        self.assertEqual(len(submitted), 1)
        self.assertEqual(submitted[0], six.text_type(self.course.id))