async def METHOD_NAME(self):
    ret = (
        await Book.annotate(avg=Avg("rating")).group_by("author_id").values("author_id", "avg")
    )
    for item in ret:
        author_id = item.get("author_id")
        avg = item.get("avg")
        if author_id == self.a1.pk:
            self.assertEqual(avg, 4.5)
        elif author_id == self.a2.pk:
            self.assertEqual(avg, 2.0)