Пример #1
0
    def test_get_distinct_count_runs_query_when_cache_empty(self):
        """ Verify that get_distinct_count runs the query and caches/returns the distinct_count."""
        course = CourseFactory()
        CourseRunFactory(title='foo', course=course)
        CourseRunFactory(title='foo', course=course)

        query = DistinctCountsSearchQuery()
        query.aggregation_key = 'aggregation_key'
        query.add_filter(SQ(title='foo'))
        query.add_model(CourseRun)

        assert query._distinct_hit_count is None
        assert query.get_distinct_count() == 1
        assert query._distinct_hit_count == 1
Пример #2
0
 def test_get_distinct_count_returns_cached_value(self):
     """ Verify that get_distinct_count returns the distinct_count from the cache when present."""
     query = DistinctCountsSearchQuery()
     query._distinct_hit_count = 123
     assert query.get_distinct_count() == 123