def testUpdateAverageRatingBatch(self):
    models.Category.buildAllCategories()
    product = docs.Product.buildProduct(PRODUCT_PARAMS)
    config.BATCH_RATINGS_UPDATE = True

    # Create a review object and invoke updateAverageRating.
    review = models.Review(product_key=product.key,
                           username='bob',
                           rating=5,
                           comment='comment'
                           )
    review.put()
    utils.updateAverageRating(review.key)

    # there should not be any task queue tasks
    taskq = self.testbed.get_stub(testbed.TASKQUEUE_SERVICE_NAME)
    tasks = taskq.GetTasks("default")
    taskq.FlushQueue("default")
    self.assertEqual(len(tasks), 0)

    # with BATCH_RATINGS_UPDATE = True, the product document's average rating
    # field ('ar') should not yet be updated to match its associated product
    # entity.
    product = models.Product.get_by_id(product.pid)
    sq = search.Query(query_string='ar:5.0')
    res = docs.Product.getIndex().search(sq)
    self.assertEqual(res.number_found, 0)
Hook that replaces the `Field` attribute on a class with a named
dataset/ETHPy150Open GoogleCloudPlatform/appengine-search-python-java/product_search_python/tests/test_search.py/FTSTestCase.testUpdateAverageRatingBatch--crossover with--dataset/ETHPy150Open coleifer/peewee/peewee.py/Field.add_to_class