'Decorates test methods to count mongo and SQL calls for a
particular modulestore.'

def count_queries(func):

    def inner(self, default_store, module_count, mongo_calls, sql_queries, *args, **kwargs):
        with modulestore().default_store(default_store):
            self.set_up_course(module_count=module_count)
            self.clear_caches()
            with self.assertNumQueries(sql_queries, table_blacklist=QUERY_COUNT_TABLE_BLACKLIST):
                with check_mongo_calls(mongo_calls):
                    func(self, *args, **kwargs)
    return inner
