Exemplo 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 override_waffle_switch(
                block_structure_config.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)
        self.assertEqual(len(submitted), 1)
        self.assertEqual(submitted[0], six.text_type(self.course.id))
Exemplo n.º 2
0
 def test_query_counts_cached(self, store_type, with_storage_backing):
     with override_waffle_switch(waffle_switch(STORAGE_BACKING_FOR_CACHE), active=with_storage_backing):
         course = self._create_course(store_type)
         self._get_blocks(
             course,
             expected_mongo_queries=0,
             expected_sql_queries=11 if with_storage_backing else 10,
         )
Exemplo n.º 3
0
    def test_query_counts_uncached(self, store_type_tuple, with_storage_backing):
        store_type, expected_mongo_queries = store_type_tuple
        with override_waffle_switch(waffle_switch(STORAGE_BACKING_FOR_CACHE), active=with_storage_backing):
            course = self._create_course(store_type)
            clear_course_from_cache(course.id)

            if with_storage_backing:
                num_sql_queries = 21
            else:
                num_sql_queries = 11

            self._get_blocks(
                course,
                expected_mongo_queries,
                expected_sql_queries=num_sql_queries,
            )